Ashutosh Kumar
Ashutosh Kumar

Reputation: 471

Why is my navigation bar not covering the whole screen?

The following is the html and css code for the navigation bar.

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}


h2,
h3,
a {
	color: #727475;
}

a {
	text-decoration: none;
}



.logo {
	margin: 0;
	font-size: 1.45em;
}

.main-nav {
	margin-top: 5px;

}
.logo a,
.main-nav a {
	padding: 10px 15px;
	text-transform: uppercase;
	text-align: center;
	display: block;
}

.main-nav a {
	color: #456279;
	font-size: .99em;
}

.main-nav a:hover {
	color: #3b556e;
}



.header {
	padding-top: .5em;
	padding-bottom: .5em;
	border: 1px solid #929292;
	background-color: #252323;
	-webkit-box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.75);
	-moz-box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.75);
	box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.75);
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
}







@media (min-width: 769px) {
	.header,
	.main-nav {
		display: flex;
	}
	.header {
		flex-direction: column;
		align-items: center;
    	/* .header{
		width: 80%;
		margin: 0 auto;
		max-width: 1150px;
	} */
	}

}

@media (min-width: 1025px) {
	.header {
		flex-direction: row;
		justify-content: space-between;
	}

}
<header class="header">
    <h1 class="logo"><a href="#">Dairy Farm Dashboard</a></h1>
      <ul class="main-nav">
          
          <li>
              <select name="" id="" class="form form-control abcdefgh" [(ngModel)]="selecteddate"  (change)="mychange()">
                  <option value="" disabled>Date</option>
                  <option value="{{date}}" *ngFor="let date of date_new">{{date}}</option>
                 
                </select>
          </li>
          <li>
              <select name="" id="" class="form form-control abcdefgh" [(ngModel)]="selectcity"  (change)="citychange()">
                  <option value="" disabled>Country</option>
                  <option value="{{city.country}}" *ngFor="let city of city">{{city.city}}</option>
                  
                 
                </select>
          </li>
          <li><a (click)="logout()">Logout</a></li>
      </ul>
  </header>

The output that I am getting is somewhat like this. The output image.

As it is clear from the picture,my navigation bar is not covering the whole screen.However even this would have been acceptable to me . The problem is that when I try to increase the browser size by pressing 'CTRL+' ,the navigation bar is not able to cover up the content below it.The following is the screenshot on expanded screens. View on enlarged screens.

What am I doing wrong here?How do I make the navigation bar cover the entire screen.

Upvotes: 1

Views: 2080

Answers (2)

Techie_T
Techie_T

Reputation: 435

I have edited your code.

I have just added margin: 0; to body as by default browsers add some margins to it. It is working fine now.

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

body {
  margin: 0;
}

h2,
h3,
a {
	color: #727475;
}

a {
	text-decoration: none;
}



.logo {
	margin: 0;
	font-size: 1.45em;
}

.main-nav {
	margin-top: 5px;

}
.logo a,
.main-nav a {
	padding: 10px 15px;
	text-transform: uppercase;
	text-align: center;
	display: block;
}

.main-nav a {
	color: #456279;
	font-size: .99em;
}

.main-nav a:hover {
	color: #3b556e;
}



.header {
	padding-top: .5em;
	padding-bottom: .5em;
	border: 1px solid #929292;
	background-color: #252323;
	-webkit-box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.75);
	-moz-box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.75);
	box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.75);
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
}







@media (min-width: 769px) {
	.header,
	.main-nav {
		display: flex;
	}
	.header {
		flex-direction: column;
		align-items: center;
    	/* .header{
		width: 80%;
		margin: 0 auto;
		max-width: 1150px;
	} */
	}

}

@media (min-width: 1025px) {
	.header {
		flex-direction: row;
		justify-content: space-between;
	}

}
<header class="header">
    <h1 class="logo"><a href="#">Dairy Farm Dashboard</a></h1>
      <ul class="main-nav">
          
          <li>
              <select name="" id="" class="form form-control abcdefgh" [(ngModel)]="selecteddate"  (change)="mychange()">
                  <option value="" disabled>Date</option>
                  <option value="{{date}}" *ngFor="let date of date_new">{{date}}</option>
                 
                </select>
          </li>
          <li>
              <select name="" id="" class="form form-control abcdefgh" [(ngModel)]="selectcity"  (change)="citychange()">
                  <option value="" disabled>Country</option>
                  <option value="{{city.country}}" *ngFor="let city of city">{{city.city}}</option>
                  
                 
                </select>
          </li>
          <li><a (click)="logout()">Logout</a></li>
      </ul>
  </header>

Upvotes: 0

Nouman Ejaz
Nouman Ejaz

Reputation: 159

add any one from below in your css because some browser has default margins.

body{
margin:0;
}

or

*{
margin:0;
}

Upvotes: 1

Related Questions