我当前的代码似乎是在做一个模式,而不是覆盖整个页面。如何使其覆盖整个页面,而不是像描述那样的图案?
<style>
body {
background: linear-gradient(120deg, #211B53, #ECE3E6);
width: 100%;
height: 100%;
}
#para1 {
text-align: center;
font-size: 600%;
color: black;
}
div.absolute {
position: absolute;
bottom: 10px;
left: 10px;
}
</style>
<p id="para1"> ARTWORK</p>
<div class="absolute"> All sales final. </div>
答案 0 :(得分:0)
使用渐变时,请确保使用正确的CSS
body {
background: linear-gradient(120deg, #211B53, #ECE3E6);
width: 100%;
min-height:100vh;
background-size: cover;
}
#para1 {
text-align: center;
font-size: 600%;
color: black;
}
div.absolute {
position: absolute;
bottom: 10px;
left: 10px;
}
<p id="para1"> ARTWORK</p>
<div class="absolute"> All sales final. </div>
你很好走!!
答案 1 :(得分:0)
与其将width
和height
分别设置为100%
,而不是将它们分别设置为100vw
和100vh
:
body {
background: linear-gradient(120deg, #211B53, #ECE3E6);
width: 100vw;
height: 100vh;
}
#para1 {
text-align: center;
font-size: 600%;
color: black;
}
div.absolute {
position: absolute;
bottom: 10px;
left: 10px;
}
<p id="para1"> ARTWORK</p>
<div class="absolute"> All sales final. </div>
答案 2 :(得分:0)
答案 3 :(得分:-1)
尝试添加:
body {
background-size: cover;
}