Home > Net >  How to make a centered menu with a logo image about 200px away from the screens edge
How to make a centered menu with a logo image about 200px away from the screens edge

Time:08-30

I need something like this, i tried alot but failed lol, im newenter image description here

CodePudding user response:

flex space between

.row {
  display: flex;
  justify-content: space-between;
}
<div >
  <div >logo</div>
  <div >menu menu menu menu</div>
  <div >anonymous</div>
</div>

CodePudding user response:

You'll need some HTML and some CSS.

I don't have the time to make you the header just like in that screenshot you postet but maybe heres a start.

Put this in the body of your HTML page:

<div >
  <a href="#default" >CompanyLogo</a>
  <div >
    <a  href="#home">Home</a>
    <a href="#contact">Contact</a>
    <a href="#about">About</a>
  </div>
</div>

<div style="padding-left:20px">
  <h1>Responsive Header</h1>
  <p>Resize the browser window to see the effect.</p>
  <p>Some content..</p>
</div>

At the beginning of your document make a block or use an external stylesheet. If you use an external stylesheet remember to link it in your HTML document.

In your style block put the following:

* {box-sizing: border-box;}

body { 
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.header {
  overflow: hidden;
  background-color: #f1f1f1;
  padding: 20px 10px;
}

.header a {
  float: left;
  color: black;
  text-align: center;
  padding: 12px;
  text-decoration: none;
  font-size: 18px; 
  line-height: 25px;
  border-radius: 4px;
}

.header a.logo {
  font-size: 25px;
  font-weight: bold;
}

.header a:hover {
  background-color: #ddd;
  color: black;
}

.header a.active {
  background-color: dodgerblue;
  color: white;
}

.header-right {
  float: right;
}

@media screen and (max-width: 500px) {
  .header a {
    float: none;
    display: block;
    text-align: left;
  }
  
  .header-right {
    float: none;
  }
}

You'll end up with a fairly responsive header. Now just link in your logo.

This is an example from w3Schools.

Check out this snippet.

* {box-sizing: border-box;}

body { 
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.header {
  overflow: hidden;
  background-color: #f1f1f1;
  padding: 20px 10px;
}

.header a {
  float: left;
  color: black;
  text-align: center;
  padding: 12px;
  text-decoration: none;
  font-size: 18px; 
  line-height: 25px;
  border-radius: 4px;
}

.header a.logo {
  font-size: 25px;
  font-weight: bold;
}

.header a:hover {
  background-color: #ddd;
  color: black;
}

.header a.active {
  background-color: dodgerblue;
  color: white;
}

.header-right {
  float: right;
}

@media screen and (max-width: 500px) {
  .header a {
    float: none;
    display: block;
    text-align: left;
  }
  
  .header-right {
    float: none;
  }
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>

<div >
  <a href="#default" >CompanyLogo</a>
  <div >
    <a  href="#home">Home</a>
    <a href="#contact">Contact</a>
    <a href="#about">About</a>
  </div>
</div>

<div style="padding-left:20px">
  <h1>Responsive Header</h1>
  <p>Resize the browser window to see the effect.</p>
  <p>Some content..</p>
</div>

</body>
</html>

  • Related