* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
:root {
--bgcolor: #083EFD;
--secondary-bgcolor: #3D68FF;
--primarycolor: #E12836;
--white-shade: #FFFFFB;
}
body {
background-color: var(--bgcolor);
color: var(--white-shade);
font-family: 'Poppins', sans-serif;
}
.navigation-bar {
background-color: var(--secondary-bgcolor);
height: 1.875rem;
width: 100%;
position: fixed;
z-index: 1;
}
.site-name{
color: var(--primarycolor);
position: sticky;
font-size: 1.5rem;
font-weight: bold;
display: inline;
margin-left: 0.5rem;
z-index: 2;
top: 0;
}
svg {
fill: var(--white-shade);
position: fixed;
right: 0.5rem;
height: 1.5rem;
top: 0.188rem;
z-index: 2;
}
.primary-headings {
font-size: 1.25rem;
font-weight: bold;
}
<div class="navigation-bar"></div>
<h2 class="site-name">MYSQUAD11</h2>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path
d="M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm6 17h-12v-2h12v2zm0-4h-12v-2h12v2zm0-4h-12v-2h12v2z" />
</svg>
<h3 class="primary-headings">Team Name</h3>
<input id="input" type="search" placeholder="Bilal Atique">
<h3 class="primary-headings">Select Tournament</h3>
<input id="input" type="search" placeholder="Search">
<button>Create Team</button>
<button>View Team</button>
<h3 class="primary-headings">Choose Players</h3>
<select>
<option>Volvo</option>
<option>Saab</option>
<option>Mercedes</option>
<option>Audi</option>
</select>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nlum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla.</p>
Why the position is not working in this element: MYSQUAD11? I want to give the h2 element position fixed instead of fixed so that the document flow is not interrupted. In this case, "flow interruption" means the below element hides behind the nav bar. If there is any other way to prevent the flow interruption that does not require modifying HTML, suggest it. Check the code snippet and help me to resolve this.
CodePudding user response:
just add blow css property to .site-map:
.site-name{
color: var(--primarycolor);
position: sticky;
font-size: 1.5rem;
font-weight: bold;
display: inline;
margin-left: 0.5rem;
z-index: 2;
top:0px;
}
just add top : 0px;