After reading an enlightening article, I decided to create a supporting example for the questions that have arisen.
body{
height:100%;
width:100%;
margin:0px;
}
h1{
margin:0;
padding:0;
}
.wrapper{
height:100vh;
background: url('https://wallpaperaccess.com/full/257525.jpg') no-repeat center center / cover;
background-attachment: fixed;
}
/* dark overlay */
.wrapper::before{
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height:100%;
background-color: rgba(33, 33, 33, 0.5);
}
.content{
position:absolute;
color:#fff;
top50%;
left:0;
right:0;
width:50%;
margin:auto;
text-align: center;
}
<div class="wrapper">
<div class="content">
<h1>
Let's write some text
</h1>
Lorem ipsum dolor sit amet consectetur adipisicing elit... // Text shortened for brevity //
</div>
</div>
- Question one delves into the positioning of text within the layout. By tweaking the CSS properties such as removing
position:absolute;
for the.content
class, it affects how the elements stack in relation to each other. - The second query brings up the issue of overflowing content causing the page to become scrollable, detracting from the intended experience. This problem prompts consideration of potential solutions to maintain the aesthetic balance.
- Is there a feasible alternative using
position:relative;
andz-index: 1;
to reach the desired outcome?
I appreciate your insights on navigating the intricacies of CSS.