[英]How can I make text drop down to a second line using media queries?
When my site is at a specific size I want the logo to break in half so that Photography & Design are on a second line. 当我的网站尺寸特定时,我希望徽标分成两半,以便摄影与设计位于第二行。 How would I accomplish this?
我将如何完成?
@media only screen and (max-width: 424px) { }
<nav> <h1 class="logo">Brian Funderburke Photography & Design</h1> </nav>
The simplest way would be to add a span that wraps around what you want to be on its own line, then target it, and assign it display: block;
最简单的方法是添加一个跨度,该跨度将您想要的内容环绕在自己的行上,然后将其定位,然后将其分配给
display: block;
I highly recommend you make this more robust with proper class name selection and so forth. 我强烈建议您使用适当的类名选择等来使它更强大。
HTML: HTML:
<nav>
<h1 class="logo">Brian Funderburke <span>Photography & Design</span></h1>
</nav>
CSS: CSS:
@media only screen and (max-width: 424px) {
.logo span {
display: block;
}
}
https://jsfiddle.net/6vcbdqqk/ https://jsfiddle.net/6vcbdqqk/
if it is only about this very h1
and this very text, then set a width
to force text to wrap. 如果仅关于此
h1
和此文本,则设置width
以强制文本换行。
@media only screen and (max-width: 424px) { h1 { width: 10em; } } .demo { width: 10em; border: solid; /* remove this, demo purpose */ }
<nav> <h1 class="logo">Brian Funderburke Photography & Design</h1> </nav> <p>below for demo</p> <h2 class="demo">Brian Funderburke Photography & Design</h2> <h3 class="demo">Brian Funderburke Photography & Design</h3> <p class="demo">Brian Funderburke Photography & Design</p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.