[英]white-space: nowrap not working
I have footer with <span>
element. 我有
<span>
元素的页脚。 In mobile screen (which I expected): 在移动屏幕中(我期望如此):
Desktop display (should not break into a new line) : 桌面显示(不应换行):
My HTML and CSS: 我的HTML和CSS:
@media screen and (min-width: 768px) { .rwd-line { display: inline; white-space: nowrap; } } .rwd-line { display: block; }
<h4 class="text-center"> <span class="rwd-line">©<?php echo date('Y') ?> PT Paket Informasi Digital<span class="visible-lg">•</span></span> <span class="rwd-line"><a href="https://blog.paket.id" target="_blank">Blog</a><span class="visible-lg">•</span></span> <span class="rwd-line"><a href="https://docs.paket.id" target="_blank">Documentation</a><span class="visible-lg">•</span></span> <span class="rwd-line"><i class="fi flaticon-phone"></i>+62 878 0878 3630</span> </h4>
I have tried: 我努力了:
nowrap
attribute in every <span class="visible-lg">
<span class="visible-lg">
添加nowrap
属性 white-space: nowrap;
white-space: nowrap;
in my css
entities but none of the above resolve my problem. 但是以上方法都不能解决我的问题。
PS : I still need the &bull
entities to be appear on desktop display PS:我仍然需要
&bull
实体出现在桌面显示器上
This is the result from copy and paste the jsfiddle @Hastig provided me: 这是复制并粘贴jsfiddle @Hastig给我的结果:
you need to declare the media query last, like this: 您需要最后声明媒体查询,如下所示:
.rwd-line {
display: block;
}
@media screen and (min-width: 768px) {
.rwd-line {
display: inline;
white-space: nowrap;
}
}
https://jsfiddle.net/xcnswLwb/ https://jsfiddle.net/xcnswLwb/
Change display:block; 更改显示:阻止; to display:inline-block;
显示:inline-block; OR Try It Once .
或尝试一次。
.rwd-line {
display: inline-block;
white-space: nowrap;
}
The answer may lie with your visible-lg class, is this what you want to happen? 答案可能在于您的visible-lg类,这是您想发生的事情吗?
(view full screen and adjust width of window) (查看全屏并调整窗口宽度)
.text-center { text-align: center; } .rwd-line { display: block; } .visible-lg { display: none; } @media (min-width: 768px) { .rwd-line { display: inline-block; white-space: nowrap; } .visible-lg { display: inline-block; padding-left: 5px; } }
<div class="text-center"> <span class="rwd-line">©<?php echo date('Y') ?> PT Paket Informasi Digital<span class="visible-lg">•</span></span> <span class="rwd-line"><a href="https://blog.paket.id" target="_blank">Blog</a><span class="visible-lg">•</span></span> <span class="rwd-line"><a href="https://docs.paket.id" target="_blank">Documentation</a><span class="visible-lg">•</span></span> <span class="rwd-line"><i class="fi flaticon-phone"></i>+62 878 0878 3630</span> </div>
fiddle 小提琴
https://jsfiddle.net/Hastig/sbub2zrv/ https://jsfiddle.net/Hastig/sbub2zrv/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.