【问题标题】:Inline-block not working because of white-space: nowrap;由于空白,内联块不起作用:nowrap;
【发布时间】:2015-02-15 16:54:07
【问题描述】:

我目前正在尝试为学校项目制作内嵌文章。 文本溢出,我不知道为什么,但我有一个想法。 当我删除空格时: nowrap; - 文本按预期进行,填充粉红色框,但随后内联不再起作用。

有什么想法吗?我附上了一个codepen。

http://codepen.io/torarne_n/pen/PwQBmx

.slider {
width: 1225px;
height: 600px;
white-space: nowrap;
overflow-y: hidden;
overflow-x: scroll;
-webkit-overflow-scrolling: touch;
padding: 1rem;
background-color: #ccc;
margin-bottom: 10px;
}

.slides {
height:500px;
width:1225px;
display: inline-block;
background-color: aqua;
}

.intro-image {
height: auto;
width: auto;
display: inline-block;
background-color: pink;
}

.intro-text {
height: auto;
width: 300px;
display: inline-block;
background-color: fuchsia;
} 

【问题讨论】:

    标签: html text overflow css


    【解决方案1】:

    问题在于内部元素继承了nowrap。只需在内部元素上将其恢复正常即可:

    .intro-text {
        height: auto;
        width: 300px;
        display: inline-block;
        background-color: fuchsia;
        white-space: normal;
    }
    

    【讨论】:

      猜你喜欢
      • 2011-03-28
      • 1970-01-01
      • 2016-04-28
      • 2015-09-08
      • 2023-03-21
      • 2011-04-26
      • 2019-05-16
      • 2017-05-08
      • 1970-01-01
      相关资源
      最近更新 更多