新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
詳解CSS圖片布局
層疊樣式表(英文全稱:Cascading Style Sheets)是一種用來表現(xiàn)HTML(標準通用標記語言的一個應用)或XML(標準通用標記語言的一個子集)等文件樣式的計算機語言。CSS不僅可以靜態(tài)地修飾網(wǎng)頁,還可以配合各種腳本語言動態(tài)地對網(wǎng)頁各元素進行格式化。

圓角圖片
實例
圓角圖片:
img {
border-radius: 8px;
}
實例
橢圓形圖片:
img {
border-radius: 50%;
}
縮略圖
我們使用 border 屬性來創(chuàng)建縮略圖。
實例
img {
border: 1px solid #ddd;
border-radius: 4px;
padding: 5px;
}
實例
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);
}
響應式圖片相冊
實例
.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%;
}
}
圖片 Modal(模態(tài))
本實例演示了如何結(jié)合 CSS 和 JavaScript 來一起渲染圖片。
首先,我們使用 CSS 來創(chuàng)建 modal 窗口 (對話框), 默認是隱藏的。
然后,我們使用 JavaScript 來顯示模態(tài)窗口,當我們點擊圖片時,圖片會在彈出的窗口中顯示:
實例
// 獲取模態(tài)窗口
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 element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
本文標題:詳解CSS圖片布局
URL鏈接:http://m.5511xx.com/article/cdsicss.html


咨詢
建站咨詢
