Html 永久2x3 CSS图像库
我有一个非常基本的图像库,我怎样才能将它固定为3列2行 这是HTML代码Html 永久2x3 CSS图像库,html,css,Html,Css,我有一个非常基本的图像库,我怎样才能将它固定为3列2行 这是HTML代码 <div id="gallery"> <div class="img"> <a target="_blank" href="klematis_big.htm"> <img src="../zeela/img/image_1.png" alt="Klematis"/> </a> <div clas
<div id="gallery">
<div class="img">
<a target="_blank" href="klematis_big.htm"> <img src="../zeela/img/image_1.png" alt="Klematis"/> </a>
<div class="descHead">
כותרת
</div>
<div class="desc">
Add a description of the image here
</div>
</div>
<div class="img">
<a target="_blank" href="klematis2_big.htm"> <img src="../zeela/img/image_1.png" alt="Klematis" /> </a>
<div class="descHead">
כותרת
</div>
<div class="desc">
Add a description of the image here
</div>
</div>
<div class="img">
<a target="_blank" href="klematis3_big.htm"> <img src="../zeela/img/image_1.png" alt="Klematis" /> </a>
<div class="descHead">
כותרת
</div>
<div class="desc">
Add a description of the image here
</div>
</div>
<div class="img">
<a target="_blank" href="klematis4_big.htm"> <img src="../zeela/img/image_1.png" alt="Klematis" /> </a>
<div class="descHead">
כותרת
</div>
<div class="desc">
Add a description of the image here
</div>
</div>
<div class="img">
<a target="_blank" href="klematis4_big.htm"> <img src="../zeela/img/image_1.png" alt="Klematis" /> </a>
<div class="descHead">
כותרת
</div>
<div class="desc">
Add a description of the image here
</div>
</div>
<div class="img">
<a target="_blank" href="klematis4_big.htm"> <img src="../zeela/img/image_1.png" alt="Klematis" /> </a>
<div class="descHead">
כותרת
</div>
<div class="desc">
Add a description of the image here
</div>
</div>
</div>
כותרת
在此处添加图像的描述
כותרת
在此处添加图像的描述
כותרת
在此处添加图像的描述
כותרת
在此处添加图像的描述
כותרת
在此处添加图像的描述
כותרת
在此处添加图像的描述
这是CSS代码
#gallery{
}
div.img {
margin: 2px;
height: auto;
width: auto;
float: right;
}
div.img img {
width: 200px; /* what is the img size*/
height: 200px;
display: inline;
margin-left: 30px;
margin-right: 30px;
margin-bottom: 20px;
border: 1px solid #ffffff;
}
/*
div.img a:hover img {
border: 1px solid #0000ff;
}*/
div.desc {
text-align: center;
font-weight: normal;
width: 120px;
margin: 30px;
}
.descHead {
margin-right: 30px;
margin-top: 20px;
margin-bottom: 15px;
font-family: Tahoma;
font-size: 24px;
color: #323232;
}
.desc {
margin-right: 30px !important;
margin-bottom: 40px !important;
font-family: Tahoma;
font-size: 14px;
color: #323232;
}
#画廊{
}
部门经理{
保证金:2倍;
高度:自动;
宽度:自动;
浮动:对;
}
部门经理经理经理{
宽度:200px;/*img的尺寸是多少*/
高度:200px;
显示:内联;
左边距:30px;
右边距:30px;
边缘底部:20px;
边框:1px实心#ffffff;
}
/*
第a部分:悬停式img{
边框:1px实心#0000ff;
}*/
分区描述{
文本对齐:居中;
字体大小:正常;
宽度:120px;
利润率:30像素;
}
德斯海德先生{
右边距:30px;
边缘顶部:20px;
边缘底部:15px;
字体系列:Tahoma;
字体大小:24px;
颜色:#323232;
}
.描述{
右边距:30px!重要;
保证金底部:40px!重要;
字体系列:Tahoma;
字体大小:14px;
颜色:#323232;
}
我会考虑使用CSS显示:表:
< P>我会考虑使用CSS显示:表:< P>如果你不能改变HTML,这就行了:.gallery {
width: /* ((width of .image including padding/margin) * 3) */
overflow: hidden;
margin: /* top: 0, right: 0, bottom: -(size of .image's bottom margin), left: -(size of .image's left margin) */
/*
yes, that's right, the left/bottom margins are negative, but it's purely presentational
for left floated .image, replace right with left
*/
}
否则,使用CSS显示属性将起作用
还应该指出,节/标题/段落标记可能比无意义的div
标记更合适。或者,figure/figcaption集合也可能适用:
如果您无法更改HTML,则可以:
.gallery {
width: /* ((width of .image including padding/margin) * 3) */
overflow: hidden;
margin: /* top: 0, right: 0, bottom: -(size of .image's bottom margin), left: -(size of .image's left margin) */
/*
yes, that's right, the left/bottom margins are negative, but it's purely presentational
for left floated .image, replace right with left
*/
}
否则,使用CSS显示属性将起作用
还应该指出,节/标题/段落标记可能比无意义的div
标记更合适。或者,figure/figcaption集合也可能适用:
CSS:grid
我更喜欢使用网格
,它将创建一个可靠的代码
试试这个
.grid容器{
显示:网格;
网格模板柱:1fr 1fr 1fr;
网格模板行:1fr 1fr;
间隙:0px 0px;
网格模板区域:
“img1\U 1 img1\U 2 img1\U 3”
“img2_1 img2_2 img2_3”;
}
.img{
边框:1px实心#000;
文本对齐:居中;
}
.img1_1{网格区域:img1_1;}
.img1_2{网格区域:img1_2;}
.img1_3{网格区域:img1_3;}
.img2_1{网格区域:img2_1;}
.img2_2{网格区域:img2_2;}
.img2_3{网格区域:img2_3;}
img1_1
img1_2
img1_3
img2_1
img2_2
img2_3
CSS:grid
我更喜欢使用网格
,它将创建一个可靠的代码
试试这个
.grid容器{
显示:网格;
网格模板柱:1fr 1fr 1fr;
网格模板行:1fr 1fr;
间隙:0px 0px;
网格模板区域:
“img1\U 1 img1\U 2 img1\U 3”
“img2_1 img2_2 img2_3”;
}
.img{
边框:1px实心#000;
文本对齐:居中;
}
.img1_1{网格区域:img1_1;}
.img1_2{网格区域:img1_2;}
.img1_3{网格区域:img1_3;}
.img2_1{网格区域:img2_1;}
.img2_2{网格区域:img2_2;}
.img2_3{网格区域:img2_3;}
img1_1
img1_2
img1_3
img2_1
img2_2
img2_3
您的图像保证尺寸相同还是不同?您的图像保证尺寸相同还是不同?