繁体   English   中英

如何根据屏幕尺寸将背景图像设置为完整而不给出高度并将内容中心放入其中

[英]How to set background image full as per screen size without giving height and make content center into it

我尝试过填充,但我认为给 HTML 内容提供 200px 填充是错误的方法,你能帮我做什么吗?

如何使所有分辨率屏幕都相同

请使用此代码:

 .hero { width: 100%; height: 100vh; background: #000 url("https://crowdforangels.com/blog/wp-content/uploads/2017/01/notebook-1280538_1920.jpg") no-repeat; background-size: cover; display: flex; align-items: center; justify-content: center; }.hero.overlay { color: #fff; text-align:center; }
 <section class="hero"> <div class="overlay"> <h1>WEB & GRAPHIC DESIGNER</h1> <a href="#">LEARN MORE</a> </div> </section>

暂无
暂无

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

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