Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在固定背景上设置固定内容?_Html_Css - Fatal编程技术网

Html 如何在固定背景上设置固定内容?

Html 如何在固定背景上设置固定内容?,html,css,Html,Css,我想知道很长一段时间了,你怎么能在固定的背景上固定文本内容 这是我的代码来解释它: CSS .background { background-attachment: fixed; width: 100%; height: 400px; } .fixed-content { position: fixed; } HTML <div class="background"> <div class="fixed-content">

我想知道很长一段时间了,你怎么能在固定的背景上固定文本内容

这是我的代码来解释它:

CSS

.background {
    background-attachment: fixed; 
    width: 100%; 
    height: 400px; 
}
.fixed-content {
    position: fixed; 
}
HTML

<div class="background">
    <div class="fixed-content">Test</div>
</div>

试验

第二个
div
的类中有一个输入错误。在你的代码中是相同的,还是你只是在写问题的时候犯了错误?我在这里发表文章的时候写错了。你是什么意思?你需要更清楚你想要什么。第二个
div
的类有一个输入错误。在你的代码中是相同的,还是你只是在写问题的时候犯了错误?我在这里发表文章的时候写错了。你是什么意思?你需要更清楚你想要什么。