I am currently working on a navigation bar for my website, and am super new to CSS and HTML.
I have a header split up into two divs, one for the top half displaying the logo, title, and login page, and another for the navigation buttons. I am running into issues, where my p tag leaves the div that it is inside of, and gets in the way of my navigation buttons. Here is an image of the issue: [1]: https://i.stack.imgur.com/MoSsk.png
What you are looking at is the inspect element view of a p tag next to an image tag, both within a div.
Here is some html:
header{
background-color: #B71C1C;
color: #FFFFFF;
position:fixed;
top:0;
left:0;
width:100%;
height:150px;
margin-left: 0px;
margin-right: 0px;
}
#bar_logo{
max-height:90px;
max-width:90px;
height:auto;
width:auto;
margin:0;
padding:0;
}
.upper_banner{
width:100%;
height:60%;
margin: 0;
padding: 0;
}
#title_banner{
margin:0;
padding:0;
display: inline;
height:60%;
font-size: 45px;
font-family: Helvetica;
text-align:center;
top: -20;
}
#login{
float: right;
margin:10px;
}
.lower_banner{
width: 100%;
height: 40%;
margin:0;
padding:0;
}
<header>
<div class="upper_banner">
<img id="bar_logo" src="https://picsum.photos/100/100" alt="Title">
<p id="title_banner">
Title of Website
</p>
<a id="login" href="login.html">login</a>
</div>
</header> <!-- added by Rickard -->
I am having some troubles working out this issue, as when I do highlighting over the div "upper_banner" it doesn't highlight past my image on the far right. As you can see, I was attempting to use
top: -20;
in an attempt to move it up 20 px, but no difference. I have a feeling that this issue is because my p tag is starting at a certain point, and because my height is set to a fixed pixel count, it is going down that number of pixels, which leads to it overflowing into the div below.
Apologies for the wicked beginner question, super new to all of this.