我只使用图片内容设置主页样式,没有文字。
当我为图像布局设置样式时,是否应该仅在div类中完成(例如,天花板>或者我是否需要设置每个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%;
}
答案 0 :(得分:0)
你可以设置'包装'的样式,即:.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;}
然后你可以给图像一个具有风格的特定类,例如:image
<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%;}