【问题标题】:Firefox negative margins and max-width greater than 100% issueFirefox 负边距和最大宽度大于 100% 问题
【发布时间】:2015-02-13 19:56:42
【问题描述】:

我为我的 Wordpress 主题制作了一个自定义代码,我认为大于 100% 的边距和/或最大宽度会导致 Firefox 溢出并显示水平滚动条。 Chrome 可以很好地呈现网站(这里是网站:http://bit.ly/1zXIxd5

这是导致问题的部分(我认为)

@media all and (min-width: 800px) {
#content img {max-width: 157.5%; height: auto; margin-left: -28.5%;}
#okv {width: 157%; margin-left: -28.5%;}
#okp {width: 80%; margin: 5% 10% 5% 10%;}
.post .featured-image {margin-left: 28.5%;}
}

因此,如果有人知道解决此问题的方法,请告诉我。如果您需要,这是我的完整自定义代码。

.header {
position: relative;
width: 100%;
display: inline-block;
padding: 2.3% 2% 0% 2%;
text-align: center;
}

.post .post-content {font: 17px/1.6 sans-serif;}

@media all and (max-width: 799px) {
#content img {max-width: 100%; height: auto;}
#okv {width: 100%; margin-left: 0;}
#okp {width: 100%; margin: 0 auto;}
.post .post-content {font: 14px/1.6 sans-serif;}
.post .featured-image {margin-left: 0;}
}

@media all and (min-width: 800px) {
#content img {max-width: 157.5%; height: auto; margin-left: -28.5%;}
#okv {width: 157%; margin-left: -28.5%;}
#okp {width: 80%; margin: 5% 10% 5% 10%;}
.post .featured-image {margin-left: 28.5%;}
}

.nav a {font-family: Arial, Helvetica, sans-serif;}

h2 {font-family: Arial, Helvetica, sans-serif;}

.post .more-link:hover span {background: #e34234;}

p.wp-caption-text {text-align: center; font: 13px/1.6 sans-serif;}

p.mtx {font: 10px/1.6 sans-serif;}

.post .more-link span {background: #f6f6f6; border-radius: 3px; padding: 6px 23px;}
.entry-title {font-weight: bold;}
.twentytwenty-handle {top: -50%;}
.twentytwenty-horizontal .twentytwenty-handle:after, .twentytwenty-horizontal .twentytwenty-handle:before {width: 1px;}

.intro {display: inherit;}

.comments-wrap {
    width: 65%;
    margin: 0px auto;
    padding: 4% 0px;
    font-size: 0.9em;
}

【问题讨论】:

    标签: html css wordpress


    【解决方案1】:

    第 178 行锚标记内的图像上的 margin-left 需要设置为 0。

    你可以这样做:

    .post .featured-image {
        margin-left: 0 !important;
    }
    
    .post .featured-image img {
        margin-left: 0 !important;
    }
    

    【讨论】:

    • 顶部的特色图像 div 向右移动了 28.5%,然后图像本身被拉回了 28.5% 的负边距。这会导致 div 被推离页面边缘,而图像位置正确。不要忘记标记我的答案正确。很高兴我能帮上忙!
    猜你喜欢
    • 2012-12-04
    • 2017-05-29
    • 2015-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-09
    • 2013-07-26
    • 2014-11-18
    相关资源
    最近更新 更多