Html 删除边缘div填充,但将图像的大小保留在此div内,并取决于此div大小
我把四个div排成一行。在这个分区内,我有响应和16:9的图像。div之间的填充应为20px,但边填充(左为左图像,右为右图像)应为0。不幸的是,我减去左img的左边缘,右img的右边缘这两幅图像更大。我知道为什么,但我有问题,找到好的方法,如何防止这种情况 html:Html 删除边缘div填充,但将图像的大小保留在此div内,并取决于此div大小,html,responsive-design,Html,Responsive Design,我把四个div排成一行。在这个分区内,我有响应和16:9的图像。div之间的填充应为20px,但边填充(左为左图像,右为右图像)应为0。不幸的是,我减去左img的左边缘,右img的右边缘这两幅图像更大。我知道为什么,但我有问题,找到好的方法,如何防止这种情况 html: 请给我一些建议,如何解决这个问题。好的,我找到了答案。对于适当的div,我使用左/右减去适当的值: .popular article.category-popular:nth-child(2){ left: -10px !i
请给我一些建议,如何解决这个问题。好的,我找到了答案。对于适当的div,我使用左/右减去适当的值:
.popular article.category-popular:nth-child(2){
left: -10px !important;
}
.popular article.category-popular:nth-child(3){
left: -5px;
}
.popular article.category-popular:nth-child(4){
right: -5px !important;
}
.popular article.category-popular:last-child{
right: -10px !important;
}
您可以关闭主题
article.category-popular {
width: 25%;
padding: 0 10px;
box-sizing: border-box;
}
article {
float: left;
position: relative;
}
article #summary-img {
width: 100%;
overflow: hidden;
margin: 0 0 20px 0;
padding-top: 56.25%;
position: relative;
}
article #summary-img a {
width: 100%;
}
article #summary-img img {
position: absolute;
top: 50%;
left: 50%;
width: 100% !important;
height: auto !important;
transform: translate(-50%, -50%);
}
article.category-popular #summary-img img {
min-height: 200px !important;
}
.popular article.category-popular:nth-child(2){
left: -10px !important;
}
.popular article.category-popular:nth-child(3){
left: -5px;
}
.popular article.category-popular:nth-child(4){
right: -5px !important;
}
.popular article.category-popular:last-child{
right: -10px !important;
}