【发布时间】:2014-09-08 03:00:31
【问题描述】:
我目前有一个博客需要在一行中显示 4 个配置文件(代理风格)列表,我已经设计了网站,以便在其响应时,并且我希望这些配置文件能够响应地工作。此时它可以工作,但是当使用 50% 没有边距时,但 id 像它们之间的 10px 空格时,当这些边距用下面的代码添加时,它们不对齐,请参见 jfiddle。
CSS
.new-agency-clients{
position: relative;
border-radius:6px;
background:#fcfbfc !important;
background:-webkit-gradient(linear,left top,left bottom,from(#fcfbfc),to(#f7f6f7)) !important;
background:-webkit-linear-gradient(#fcfbfc,#f7f6f7) !important;
background:-moz-linear-gradient(center top,#fcfbfc 0,#f7f6f7 100%) !important;
background:-moz-gradient(center top,#fcfbfc 0,#f7f6f7 100%) !important;
width:940px;
height: 100%;
box-shadow:0 0 3px #444;
-moz-box-shadow:0 0 3px #444;
-webkit-box-shadow:0 0 3px #444;
padding-top: 10px;
margin-top:10px;
margin-bottom:10px;
}
.new-agency-clients-box {
overflow:hidden;
}
.new-agency-clients-box .entry-profile {
bottom:0;
top:0;
left:0;
right:0;
margin-left:10px;
margin-bottom: 10px;
float:left;
position:relative;
width: 225px;
height: 270px;
background: #ffffff;
border-radius: 6px;
overflow:hidden;
box-shadow:0 0 3px #444;
-moz-box-shadow:0 0 3px #444;
-webkit-box-shadow:0 0 3px #444;
}
.new-agency-clients-box .entry-profile .profilename {
margin-top: -35px;
line-height: 26px;
height: 28px;
width: 100%;
background:#cccccc;
background:-webkit-gradient(linear,left top,left bottom,from(#eeeeee),to(#cccccc)); background:-webkit-linear-gradient(#eeeeee,#cccccc);
background:-moz-linear-gradient(center top,#eeeeee 0,#cccccc 100%);
background:-moz-gradient(center top,#eeeeee 0,#cccccc 100%);
color: #444;
display: block;
font-size: 14px;
font-weight: bold;
position: relative;
border-radius: 0px !important;
}
.new-agency-clients-box .entry-profile .profile-box-image{
background: #0e0e0e !important;
width: 225px;
height: 270px;
margin-bottom: 10px;
cursor: pointer;
position: relative;
}
.new-agency-clients-box .entry-profile .profile-box-image:hover{
filter: alpha(opacity=60,Style=0);
opacity: 0.6;
cursor: pointer;
}
.new-agency-clients-box .entry-profile .profile-box-image a img{
width: 225px;
height: 270px;
position: absolute;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.new-agency-clients-box .entry-profile .profile-box-image a img.default{
width: 225px;
height: auto;
position: absolute;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
@media only screen and (max-width: 750px) {
.wrap {width: auto;}
.new-agency-clients {width: 100%;}
.new-agency-clients-box .entry-profile {width: 50%; height: 50%;}
}
HTML
<div class="new-agency-clients">
<div class="new-agency-clients-box">
<div class="entry-profile">
<div class="profile-box-image">
<a href="" rel="bookmark">
<img width="700" height="875" src="" class="attachment-post-thumbnail wp-post-image" alt="" />
</a>
</div>
<center>
<div class="profilename">
<h6><a href="" rel="bookmark" title="">Profile</a></h6>
</div>
</center>
</div>
<div class="entry-profile">
<div class="profile-box-image">
<a href="" rel="bookmark">
<img width="700" height="875" src="" class="attachment-post-thumbnail wp-post-image" alt="" />
</a>
</div>
<center>
<div class="profilename">
<h6><a href="" rel="bookmark" title="">Profile</a></h6>
</div>
</center>
</div>
<div class="entry-profile">
<div class="profile-box-image">
<a href="" rel="bookmark">
<img width="700" height="875" src="" class="attachment-post-thumbnail wp-post-image" alt="" />
</a>
</div>
<center>
<div class="profilename">
<h6><a href="" rel="bookmark" title="">Profile</a></h6>
</div>
</center>
</div>
<div class="entry-profile">
<div class="profile-box-image">
<a href="" rel="bookmark">
<img width="700" height="875" src="" class="attachment-post-thumbnail wp-post-image" alt="" />
</a>
</div>
<center>
<div class="profilename">
<h6><a href="" rel="bookmark" title="">Profile</a></h6>
</div>
</center>
</div>
</div>
</div>
【问题讨论】:
-
请将其缩减为重现问题所需的最少代码集。我假设您在尝试追踪它的过程中已经做了什么?
-
@torazaburo,他确实添加了准确的最小代码来描述他的问题
-
@Fabio 我相信你的话,对我来说似乎有很多多余的东西。
标签: html css margin percentage