简体   繁体   English

空格:普通内部空格:nowrap

[英]white-space:normal inside white-space:nowrap

I want to put a list of SPAN with white-space:normal inside a span with white-space:nowrap. 我想将带有white-space:normal的SPAN列表放在带有white-space:nowrap的范围内。 when i try the code above in firefox works. 当我尝试上述代码在Firefox的作​​品。 when i try in the chrome don't work. 当我尝试使用chrome时不起作用。 how to fix it? 如何解决?

<div style="overflow: auto; width: 100%; white-space: nowrap;" class="well">

            <span style="margin: 10px; position: relative;">
                <img data-src="holder.js/150x150" class="img-rounded img-polaroid" alt="150x150" style="width: 150px; height: 150px;">
                <a href="/promo-web/promocao/13">
                    <span style="position: absolute; left: 5px;white-space:normal">alienígenas de são cristovão e o melhor do sorvete</span>
                </a>


            </span>

            <span style="margin: 10px; position: relative;">
                <img data-src="holder.js/150x150" class="img-rounded img-polaroid" alt="150x150" style="width: 150px; height: 150px;">
                <a href="/promo-web/promocao/13">
                    <span style="position: absolute; left: 5px;white-space:normal">alienígenas de são cristovão e o melhor do sorvete</span>
                </a>


            </span>

            <span style="margin: 10px; position: relative;">
                <img data-src="holder.js/150x150" class="img-rounded img-polaroid" alt="150x150" style="width: 150px; height: 150px;">
                <a href="/promo-web/promocao/13">
                    <span style="position: absolute; left: 5px;white-space:normal">alienígenas de são cristovão e o melhor do sorvete</span>
                </a>


            </span>
...

You are missing some concepts about html & css. 您缺少有关html和css的一些概念。

  • Separe css from html. 从HTML分离CSS。
  • For containers, use div . 对于容器,请使用div Use span just to style inline elements. 仅将span用作内联元素的样式。
  • Don't abuse on creating to many DOM elements. 不要滥用于创建许多DOM元素。

See my solution (instead of div you can use ul & li too). 请参阅我的解决方案(也可以使用ulli代替div )。 Also, if possible, show the image as a background-image instead creating a img tag and applying absolute positioning. 此外,如果可能的话,显示该图像作为a背景图像,而不是创建一个img标签和应用绝对定位。

http://jsfiddle.net/jvHZq/ http://jsfiddle.net/jvHZq/

HTML: HTML:

<div class="well">
    <div>
        <img data-src="holder.js/150x150" class="img-rounded img-polaroid" />
        <a href="/promo-web/promocao/13">alienígenas de são cristovão e o melhor do sorvete</a>
    </div>
    <div>
        <img data-src="holder.js/150x150" class="img-rounded img-polaroid" />
        <a href="/promo-web/promocao/13">alienígenas de são cristovão e o melhor do sorvete</a>
    </div>
    <div>
        <img data-src="holder.js/150x150" class="img-rounded img-polaroid" />
        <a href="/promo-web/promocao/13">alienígenas de são cristovão e o melhor do sorvete</a>
    </div>
</div>

CSS: CSS:

.well {
    overflow: auto;
    width: 100%;
    white-space: nowrap;   
}
.well > div {
    float: left;
    position: relative;
    white-space:normal;
    width: 33%;
}
img {
    width: 150px; height: 150px;   
}
a {
    position: absolute;
    top: 0;
    left: 5px;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM