【发布时间】:2016-08-29 19:45:09
【问题描述】:
我的网页有 4 张背景图片,每张都需要全屏显示。在每个背景上,我都有一些标签和文本。这是CSS代码,我将在代码部分之后解决问题。
html{
height:100%;
}
body{
font-family:'Roboto', sans-serif;
color:#fff;
-webkit-font-smoothing:antialiased;
-moz-osx-font-smoothing:grayscale;
height:100%;
}
.section{
background-attachment:inherit;
background: no-repeat center center fixed;
height:100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size:cover;
}
通过使用这种风格。所有背景图像都可以全屏显示。但是,当我将浏览器窗口的高度调整为较小的高度时,背景 1 上的标签 $ 文本开始跨越背景 1 和背景 2。 如果我删除“height:100%”或改用“min-height:100%”。每个背景图像永远不会全屏显示,但是当我将浏览器窗口的大小调整为较小的高度时,我不会在两个连续的背景图像中获取我的标签和文本。请帮忙
这是我的前两个图像背景的 HTML。我需要每个图像背景在任何设备上全屏显示,我的文本字段在每个背景上看起来都很好。这里我的问题是,当我缩小浏览器的高度时,由于文本字段的高度>浏览器的高度,一些文本会消失(被下一个背景覆盖)
<!-- Page Top Section -->
<div id="page-top" class="section" data-background-image="/images/background/page-top.jpg" style='background-image: url("/images/background/page-top.jpg");'>
<div class="pattern height-resize">
<div class="container">
<h1 class="site-title">
hello I am site title
</h1><!-- /.site-title -->
<h2 class="section-title">
hello I am section-1
</h2>
<div class="next-section">
<a class="go-to-about"><span></span></a>
</div><!-- /.next-section -->
</div><!-- /.container -->
</div><!-- /.pattern -->
</div><!-- /#page-top -->
<!-- Page Top Section End -->
<!-- About Us Section -->
<section id="about" class="section" data-background-image="/images/background/about-us.jpg" style='background-image: url("/images/background/about-us.jpg");'>
<div class="pattern height-resize">
<div class="container">
<h3 class="section-name">
<span>
SECTION NAME
</span>
</h3><!-- /.section-name -->
<h2 class="section-title">
SECTION TITLE
</h2><!-- /.Section-title -->
<p class="section-description">
FJDKLASJLKFJASDKLJFLKSJFLKDJSAKLFJDLKSAJ
</p><!-- /.section-description -->
<div class="next-section">
<a class="go-to-subscribe"><span></span></a>
</div><!-- /.next-section -->
</div><!-- /.container -->
</div><!-- /.pattern -->
</section><!-- /#about -->
<!-- About Us Section End -->
部分标题css: .section-title{ 文本对齐:居中; 文本转换:大写; 字体粗细:300; 字体大小:80px; }
【问题讨论】:
-
当您讨论文本/标签的呈现问题时,查看 HTML 和功能代码会很有帮助。现在我们只知道整个故事的一小部分。
-
您是否正在寻找一种解决方案,让您在所有可能的设备上拥有 4 个高度和宽度为 100% 的背景?
-
是的,但更多,我会在一分钟内添加我的 html。非常感谢您的回复
-
嗨,请查看我对 HTML 部分的编辑。谢谢:)
-
我明白了。对于这种情况,您需要使用媒体查询或纯视口单元。我推荐媒体查询,因为它们有更好的浏览器支持并且更灵活。我更新了我的答案,如果您需要更多信息,请随时询问。
标签: css