我只使用图像内容设计主页,不使用文本。
当我设置图像布局的样式时,是否应该只在 div 类中完成(例如 ceiling> 还是我需要设置每个 img 类的样式(.ceiling > a > img)
只是有意识的,我将深入了解这里的样式,因为它可以设置在顶级 div 中。
<div class="category4block">
<div class="ceiling"><a href="http://example.com/ceiling"><img src="http://example.com/image/data/Home Page /Ceiling.jpg" /></a></div>
<div class="wall"><a href="http://example.com/wall"><img src="http://example.com/image/data/Home Page /Wall.jpg" /></a></div>
<div class="island"><a href="http://example.com/island"><img src="http://example.com/image/data/Home Page /Island.jpg" /></a></div>
<div class="downwall"><a href="http://example.com/downwall"><img src="http://example.com/image/data/Home Page /Downwall.jpg" /></a></div>
</div>
.category4block {
width: 100%;
margin-left: -10px;
clear:both;
}
.ceiling {
float: left;
width: 23%;
margin-left: 5px;
margin-bottom: 20px;
}
.ceiling > a > img {
border-style: solid;
border-width: 10px;
max-height: 240px;
max-width: 100%;
width: 100%;
}
.wall {
float: left;
width: 23%;
margin-left: 22px;
margin-bottom: 20px;
}
.wall > a > img{
border-style: solid;
border-width: 10px;
max-height: 240px;
max-width: 100%;
width: 100%;
}
.island {
float: left;
width: 23%;
margin-left: 22px;
margin-bottom: 20px;
}
.island > a > img{
border-style: solid;
border-width: 10px;
max-height: 240px;
max-width: 100%;
width: 100%;
}
.downwall {
float: left;
width: 23%;
margin-left: 22px;
margin-bottom: 20px;
}
.downwall > a > img{
border-style: solid;
border-width: 10px;
max-height: 240px;
max-width: 100%;
width: 100%;
}
最佳答案
您可以只设置“包装器”的样式,即:.ceiling、.wall、.island、.downwall
.ceiling{float: left; width: 23%; margin-left: 5px; margin-bottom: 20px;}
.wall, .island, .downwall{float: left; width: 23%; margin-left: 22px; margin-bottom: 20px;}
然后你可以给图像一个特定的类,它将有风格,例如:图像
<img class="image" src="YOUR_IMAGE_SOURCE" />
<img class="image" src="YOUR_IMAGE_SOURCE" />
<img class="image" src="YOUR_IMAGE_SOURCE" />
<img class="image" src="YOUR_IMAGE_SOURCE" />
.image{border-style: solid; border-width: 10px; max-height: 240px; width: 100%;}
关于html - 设置主页图像布局的样式 - 目标 div 或 img?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33997599/