? ???? CSS? ???? ???? ?????? ??? ?????.


?? ???

Example

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<style>
img {
    border-radius: 8px;
}
</style>
</head>
<body>
<h2>圓角圖片</h2>
<p>使用 border-radius 屬性來創(chuàng)建圓角圖片:</p>
<img src="https://img.php.cn/upload/course/000/000/004/580989ec73194566.jpg" alt="Paris" width="400" height="300">
</body>
</html>

Example

??? ???:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<style>
img {
    border-radius: 50%;
}
</style>
</head>
<body>
<h2>橢圓形圖片</h2>
<p>使用 border-radius 屬性來創(chuàng)建橢圓形圖片:</p>
<img src="https://img.php.cn/upload/course/000/000/004/580989ec73194566.jpg" alt="Paris" width="400" height="300">
</body>
</html>



Thumbnail

border ??? ?????? ?? ???? ????. . border 屬性來創(chuàng)建縮略圖。

實例

img {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
}
<img src="https://img.php.cn/upload/course/000/000/004/580989ec73194566.jpg" alt="Paris">

實例

a {
    display: inline-block;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    transition: 0.3s;
}
a:hover {
    box-shadow: 0 0 2px 1px rgba
    (0, 140, 186, 0.5);
}
<a href="paris.jpg">
  <img src="https://img.php.cn/upload/course/000/000/004/580989ec73194566.jpg" alt="Paris">
</a>


響應(yīng)式圖片

響應(yīng)式圖片會自動適配各種尺寸的屏幕。

實例中,你可以通過重置瀏覽器大小查看效果:

Norway

如果你需要自由縮放圖片,且圖片放大的尺寸不大于其原始的最大值,則可使用以下代碼:

實例

img {
    max-width: 100%;
    height: auto;
}

圖片文本

如何定位圖片文本:

實例

Norway
左下角
左上角
右上角
右下角
居中

卡片式圖片

實例

div.polaroid {
    width: 80%;
    background-color: white;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
img {width: 100%}
div.container {
    text-align: center;
    padding: 10px 20px;
}

圖片濾鏡

CSS filter

Instances

img 
{
    
-webkit-filter:
 grayscale(100%);
 
/* Chrome, Safari, 
Opera */
     
    
filter:
 grayscale(100%);
}
Instances

.responsive {
    padding: 0 6px;
    float: left;
    width: 24.99999%;
}
@media only screen and (max-width: 700px){
    .responsive {
        width: 49.99999%;
        margin: 6px 0;
    }
}
@media only screen and (max-width: 500px){
    .responsive {
        width: 100%;
    }
}

??? ???
??? ???? ??? ??? ??? ???? ?????.

????? ???? ??? ????? ??? ??? ? ????.

 ????

??? ??? ???? ???? ?? ???? ??? ??? ?? ????? ?? ?? ?? ??? ??? ? ????. ?? ??:


??

var modal = document.getElementById('myModal');
// 獲取圖片模態(tài)框,alt 屬性作為圖片彈出中文本描述
var img = document.getElementById('myImg');
var modalImg = document.getElementById("img01");
var captionText = document.getElementById("caption");
img.onclick = function(){
    modal.style.display = "block";
    modalImg.src = this.src;
    modalImg.alt = this.alt;
    captionText.innerHTML = this.alt;
}
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on <span> (x), close the modal
span.onclick = function() { 
    modal.style.display = "none";
}

?? ???

?? ??? ?? ?? ??:

Example

????
?? ??
?? ??

??? ??

??? ??

??

???? ??? ????????Example???? rrreee????????Image Filter????CSS filter ??? ??? ??? ??(?: ?? ? ??)? ???? ? ?????. ????????: ?? Internet Explorer?? ?? Safari 5.1(? ?? ??)??? ? ??? ???? ????. ????????????? ??? ??? ??(100% ???)?? ??:????rrreee????????????? ?? ?????????????rrreee???????? ???? ???? ??( ?? ??)????? ???? CSS? JavaScript? ???? ???? ?? ????? ??? ?????. ?????? CSS? ???? ????? ??? ?? ?? ?(?? ??)? ????. ?????? ?? JavaScript? ???? ???? ???? ???? ?? ?? ?????. ??????Instance??????// ?? ? ????????rrreee???? ??
???? ??
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <style> img { border-radius: 8px; } </style> </head> <body> <h2>圓角圖片</h2> <p>使用 border-radius 屬性來創(chuàng)建圓角圖片:</p> <img src="https://img.php.cn/upload/course/000/000/004/580989ec73194566.jpg" alt="Paris" width="400" height="300"> </body> </html>