【问题标题】:Chrome does not show pictures inlineChrome 不显示图片内联
【发布时间】:2016-06-09 16:29:21
【问题描述】:

有没有人遇到过在谷歌Chrome浏览器中inline不显示图片的问题,即使使用了display:inline-block和其他css代码?在任何其他浏览器中,所有内容都按预期进行描绘。然而,第 4 张图片只是在 Chrome 中打开网站时突然出现在另一排。

问题看起来像这样:

代码:

HTML

<head>
 <meta charset="utf-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <title></title>
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
 <link rel="stylesheet" href="css/styles.css">
</head>


<li class="timeline-inverted">
            <div class="timeline-panel">
                <div class="timeline-heading">
                    <h4 class="timeline-title">1981-1990</h4>
                </div>
                <div class="timeline-body">
                    <p>Some text</p>
                    <p>Some more text</p>
                </div>
            </div><div class="timeline-picture-body">
                <img class="timeline-images-left padding-bottom" src="http://placehold.it/250x250">
                <img class="timeline-images-left padding-bottom" src="http://placehold.it/250x250">
                <img class="timeline-images-left align" src="http://placehold.it/250x250">
                <img class="timeline-images-left align" src="http://placehold.it/250x250">
            </div>
</li>

CSS

/*body*/
body {
 background-color: white;
}
.panel {
 background-color: white;
 color: black;
 border-radius: 0;
 text-align: justify;
 font-size: 1.3em;
}
.panel-extra {
 padding: 10px 0;
 margin-top: 25px;
 background-color: lightgrey;
 border-radius: 0;
 text-align: center;
 font-size: 1.3em;
 font-weight: bold;
}
.box {
 padding-top: 30px;
 padding-bottom: 30px;
 border-bottom-width: 3px;
 border-bottom-color: lightgrey;
 border-bottom-style: solid; 
}
/*Timeline*/

.timeline {
list-style: none;
padding: 20px 0 20px;
position: relative;
}

.timeline:before {
    top: 0;
    bottom: 0;
    position: absolute;
    content: " ";
    width: 3px;
    background-color: #eeeeee;
    left: 50%;
    margin-left: -1.5px;
}

.timeline > li {
    margin-bottom: 20px;
    position: relative;
}
.timeline > li:before,
.timeline > li:after {
    content: " ";
    display: table;
    }

.timeline > li:after {
    clear: both;
    }

.timeline > li > .timeline-panel {
    width: 46%;
    float: left;
    border: 1px solid #d4d4d4;
    border-radius: 2px;
    padding: 20px;
    position: relative;
    -webkit-box-shadow: 0 1px 6px rgba(0, 0, 0, 0.175);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.175);
    margin-bottom: 40px;
}
.timeline > li.timeline-inverted > .timeline-panel {
        float: right;
    }

    .timeline > li.timeline-inverted > .timeline-panel:before {
        border-left-width: 0;
        border-right-width: 15px;
        left: -15px;
        right: auto;
    }

    .timeline > li.timeline-inverted > .timeline-panel:after {
        border-left-width: 0;
        border-right-width: 14px;
        left: -14px;
        right: auto;
    }
.timeline > li.timeline-inverted > .timeline-picture-body: before {
        position: absolute;
        top: 26px;
        right: -15px;
        display: inline-block;
        border-top: 15px solid transparent;
        border-left: 15px solid #ccc;
        border-right: 0 solid #ccc;
        border-bottom: 15px solid transparent;
        content: " ";
    }
    .timeline > li.timeline-inverted > .timeline-picture-body: after {
        position: absolute;
        top: 27px;
        right: -14px;
        display: inline-block;
        border-top: 14px solid transparent;
        border-left: 14px solid #fff;
        border-right: 0 solid #fff;
        border-bottom: 14px solid transparent;
        content: " ";
    }
    .timeline > li.timeline-inverted > .timeline-picture-body {
        float: left;
    }
.timeline-title {
 margin-top: 0;
 color: inherit;
}

.timeline-body > p,
.timeline-body > ul {
 margin-bottom: 0;
}

.timeline-body > p + p {
 margin-top: 5px;
}
.timeline-images-right {
 display: inline-block;
 vertical-align: top;
 width: 40%;
 float: left;
 padding: 0 10px;
}
.timeline-images-left {
 display: inline-block;
 vertical-align: top;
 width: 40%;
 float: right;
 padding: 0 10px;
}
.padding-bottom {
 padding-bottom: 10px;
}
.align {
 display: block;
}

/*fonts*/
h1 {
 text-align: center;
 font-size: 3em;
 color: black;
 padding-top: 220px;
 margin-top: 0;
}
.box h1 {
 text-align: center;
 font-size: 3em;
 color: black;
 padding-top: 30px;
 margin-top: 0;
}
h2{
 text-align: center;
 font-size: 2.3em;
 color: black;
}
p {
 text-align: justify;
 font-size: 1.3em;
}

【问题讨论】:

  • 你能给我们示例代码吗?
  • @LeonLaci 添加了完整代码
  • 您应该只添加特定于该问题的代码,而不是整个代码。你的身体标签在哪里?
  • 我无法重现您在 jsfiddle 中遇到的问题:jsfiddle.net/LzLvpgng
  • 这不是网站的全部代码,只是样式和相关的 html 块。因此,也没有正文标记,因为它们位于标题下方和相关代码部分上方。但是,问题不在于代码,我已经尝试了 jsfiddle 中的所有内容,并且效果很好。我认为谷歌浏览器必须有一些默认功能会改变一些东西。但我不是专家,因此,上面的问题。如果您愿意,我可以在上面的代码中插入 body 标签。

标签: html css twitter-bootstrap google-chrome inline


【解决方案1】:

由于正在使用引导程序,因此在代码中的第二张图片之后插入&lt;div class="clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"&gt;&lt;/div&gt; 可以解决问题。

            <div class="timeline-picture-body">
                <img class="timeline-images-left padding-bottom" src="http://placehold.it/250x250">
                <img class="timeline-images-left padding-bottom" src="http://placehold.it/250x250">
                <div class="clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"></div>
                <img class="timeline-images-left align" src="http://placehold.it/250x250">
                <img class="timeline-images-left align" src="http://placehold.it/250x250">
            </div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-09
    • 2021-07-11
    相关资源
    最近更新 更多