Is there a way to put an h1 between two floating elements? - html

I am trying to get the title of a website to sit between a logo and a nav bar, while also wrapping under the nav bar.
I have tried floating the logo left and the nav element right but the nav sits under the h1. This is due to the layout of the html markup which I am not allowed to modify.
This is the desired result:
header figure {
display: inline-block;
margin: 0px;
margin-right: 40px;
float: left;
}
nav {
float: right;
}
nav ul {
padding: 0px;
margin: 0px;
}
nav li {
display: inline-block;
text-align: center;
width: 70px;
padding: 2px 4px;
border-style: dotted;
border-width: 1px;
}
h1 {
font-family: 'great-vibes';
font-size: 50px;
margin: 0px;
}
<header>
<figure>
<img src="./images/logo.png" alt="MUHC Logo" width="125" height="125">
</figure>
<h1>Welcome To The Mosgiel Underwater Hockey Club</h1>
<nav>
<ul>
<li>Home</li>
<li><a>About</a></li>
<li>League</li>
<li>Ethics</li>
</ul>
</nav>
</header>

Unable to move the elements in the DOM, you need to do two things. Use absolute positioning to move the menu to the top right hand corner, and construct a float using a before pseudo element inside the h1 element to leave room for the menu so the text doesn't overlap it. Something like this:
#import url('https://fonts.googleapis.com/css?family=Great+Vibes&display=swap');
header {
position:relative;
}
header figure {
display: inline-block;
margin: 0px;
margin-right: 20px;
float: left;
}
nav {
position:absolute;
right:0;
top:0;
}
nav ul {
padding: 0px;
margin: 0px;
}
nav li {
display: inline-block;
text-align: center;
width: 70px;
padding: 2px 4px;
border-style: dotted;
border-width: 1px;
}
h1 {
font-family: 'Great Vibes', cursive;
font-size: 40px;
margin: 0px;
overflow:auto;
}
h1:before {
content: '';
float: right;
width: 340px;
min-width: calc(100% - 6em);
height:1em;
}
<header>
<figure>
<img src="http://placehold.it/125" alt="MUHC Logo" width="125" height="125">
</figure>
<h1>Welcome To The Mosgiel Underwater Hockey Club</h1>
<nav>
<ul>
<li>Home</li>
<li><a>About</a></li>
<li>League</li>
<li>Ethics</li>
</ul>
</nav>
</header>

you can add float attribute in h1 style
like the following:
<h1 style="float:left"></h1>

You can achieve most of your desired result through absolute-positioning and flexbox, but your h1 text must change so that it breaks after the "welcome to" part.
See the result in full page mode.
header{
display:flex;
align-items:center;
position:relative;
border:1px solid;
border-radius:10px;
padding:10px;
}
header figure{
display: inline-block;
margin: 0px;
margin-right: 40px;
float: left;
}
nav{
/* float: right; */
}
nav ul{
position:absolute;
top:10px;
right:10px;
display:flex;
padding: 0px;
margin: 0px;
}
nav li{
display: inline-block;
text-align: center;
width: 70px;
padding: 2px 4px;
border-style: dotted;
border-width: 1px;
}
h1{
font-family: 'great-vibes';
font-size: 50px;
margin: 0px;
}
<header>
<figure>
<img src="//unsplash.it/125" alt="MUHC Logo" width="125" height="125">
</figure>
<h1>Welcome To The Mosgiel Underwater Hockey Club</h1>
<nav>
<ul>
<li>Home</li>
<li><a>About</a></li>
<li>League</li>
<li>Ethics</li>
</ul>
</nav>
</header>

Try putting display:inline-block or display:inline on the h1.
A good way to try things out like that is the DOM Inspector which is
available in Firefox or Chrome.
Firefox: Tools -> Web Developer -> Inspector
Chrome: 3-bar Menu -> More tools -> Developer tools -> Elements tab
or in either one:
Right-click an element (such as your H1) and choose "Inspect" or "Inspect Element" from the menu
Once you are in the Inspector, you can add, delete, or modify CSS rules as you please on a temporary basis.
When you are happy with the result, you can go back and update your source to incorporate the change.
Edit:
A simple change that worked:
Reduce the font-size on the H1 so it all fits better,
and put max-width on it as well so all three fit in the space available.

Apply width to figure and h1 also and set nav to position:absolute using css for your desired result
header{
position:relative;
}
header figure {
display: inline-block;
margin: 0px;
margin-right: 40px;
float: left;
width:100px;
}
nav {
position: absolute;
right: 0;
top: 0;
}
nav ul {
padding: 0px;
margin: 0px;
}
nav li {
display: inline-block;
text-align: center;
width: 70px;
padding: 2px 4px;
border-style: dotted;
border-width: 1px;
}
h1 {
font-family: 'great-vibes';
font-size: 30px;
margin: 0px;
width:calc(100% - 140px);
float:left;
padding-top:25px;
}
<header>
<figure>
<img src="./images/logo.png" alt="MUHC Logo" width="125" height="125">
</figure>
<h1>Welcome To The Mosgiel Underwater Hockey Club</h1>
<nav>
<ul>
<li>Home</li>
<li><a>About</a></li>
<li>League</li>
<li>Ethics</li>
</ul>
</nav>
</header>

What you are trying to achieve is not possible with single h1 tag. Instead you need to create two separate dom elements inside h1. As you need to break the line after the word Welcome To.
Check the following snippet how to do. Also you can play with other elements style.
html,
body {
padding: 0;
margin: 0;
}
header {
position: relative;
}
header figure {
/* display: inline-block; */ /* <-- Not required when using float */
float: left;
margin: 0px;
margin-right: 40px;
}
nav {
float: right;
}
nav ul {
padding: 0px;
margin: 0px;
}
nav li {
display: inline-block;
text-align: center;
width: 70px;
padding: 2px 4px;
border-style: dotted;
border-width: 1px;
}
h1 {
font-family: "great-vibes";
font-size: 40px;
margin: 0px;
position: absolute;
left: 140px;
}
p {
margin: 0;
}
<header>
<figure>
<img src="https://img.icons8.com/ios/2x/stackoverflow-filled.png" alt="MUHC Logo" width="100" height="100" />
</figure>
<h1>
<p>Welcome To</p>
<p>
The Mosgiel Underwater Hockey Club
</p>
</h1>
<nav>
<ul>
<li>Home</li>
<li><a>About</a></li>
<li>League</li>
<li>Ethics</li>
</ul>
</nav>
</header>

I would suggest you use flex css. This way it is much easier to handle the responsiveness of your page. I have done a test code using the flex css. Hope it solves your problem
HTML
nav ul {
padding: 0px;
margin: 0px;
}
nav li {
display: inline-block;
text-align: center;
width: 70px;
padding: 2px 4px;
border-style: dotted;
border-width: 1px;
}
h1 {
font-family: 'great-vibes';
font-size: 50px;
margin: 0px;
}
.d-flex {
display: flex;
}
.flex-row {
display: flex;
flex-direction: row;
}
.logo {
margin-right: 10px;
}
<header>
<div class="d-flex flex-row">
<div class="logo">
<img src="./images/logo.png" alt="MUHC Logo" width="125" height="125">
</div>
<div>
<h1>Welcome To <br/>The Mosgiel Underwater Hockey Club</h1>
</div>
<div>
<nav>
<ul>
<li>Home</li>
<li><a>About</a></li>
<li>League</li>
<li>Ethics</li>
</ul>
</nav>
</div>
</div>
</header>
JS Fiddle Link : https://jsfiddle.net/SJ_KIllshot/2eydLcmz/

Related

How to position in parallel navigation bar and logo

I have this HTML code:
<body>
<header id="masthead">
<div id="container">
<!-- logo -->
<img src="logo.png" alt="" width="200px" class="logo">
<nav>
<ul>
<li>Home</li>
<li>About Us</li>
<li>Contact Us</li>
<li>About Developers</li>
<li>History</li>
<li>Economy</li>
<li>Why Study in Dublin?</li>
<li>People and Culture</li>
</ul>
</nav>
</div>
</header>
And this CSS code:
.container {
width: 80%;
margin: 0 auto;
}
.logo {
float: left;
padding: 10px 0;
}
nav {
float: right;
}
header::after {
content : '';
display: table;
clear: both;
}
nav li {
display: inline-block;
margin-left: 70px;
padding-top: 2px;
position: relative;
padding-right: 0.1rem;
}
nav a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 14px;
}
However I want to make my nav bar to the left from the logo, but not down below. How can I do it using the given initial code that i hav pointed ? As you can see, align: right and align: left has been used, but had not helped me
Like on photo (Used arrows to point it )
Create two columns. In one column, place your logo, and in the second column, place your navigation bar.
<div class="row">
<div class="column" style="background-color:#aaa; width:20%;">
<!--pLACE Logo here--->
</div>
<div class="column" style="background-color:#bbb; width:80%">
<!--Place Navbar code here-->
</div>
</div>
Remember Adjust your css accordingly
Give your div with id container a display property of flex, direction property of row and then align or justify items as per your liking
#container{
display:flex;
flex-direction:row;
justify-content:space-between;
}
Also in your HTML code you've given tags ids but you're using class selectors in your CSS
Some resources that'll help you:
A Complete Guide to Flexbox
Basic Concepts of Flexbox
Flexbox Cheatsheet
You will have to change your CSS as shown below:
/*add this line to adjust paddings on the columns and remove default margin padding for all the html elements*/
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/*change class to # it's ID and not class*/
#container {
width: 80%;
margin: 0 auto;
}
/*recommended to add width in percentage in css and remove fix width from <img width='200px' /> tag*/
.logo {
float: left;
width:20%;
padding: 10px 0;
}
/*add width 80% for <nav> tag*/
nav {
float: right;
width: 80%;
margin-top: 10%;
}
nav li {
display: inline-block;
/* margin-left: 70px; */ /*remove*/
/* padding-top: 2px; */ /*remove*/
position: relative;
/* padding-right: 0.1rem; */ /*remove*/
padding: 0 5px; /*instead add this for space between li content*/
}
I would recommend you to use CSS FLEXBOX.
I used flexbox to do this. your id="container" was not the same as the CSS so I changed it to class="container"
I added some simple 1px borders just to illustrate what is where on the page.
This is likely not a finished solution and only a starting point.
.container {
width: 90%;
margin: 0 auto;
display: flex;
flex-direction: row;
flex: space-between font-size: 16px;
justify-content: center;
align-items: center;
}
.logo {
padding: 10px 0;
height: 3em;
border: 1px solid lime;
}
header::after {
content: '';
display: table;
clear: both;
}
nav {
border: 1px solid cyan;
justify-content: center;
align-items: center;
}
nav ul li::before {
content: "\200B";
}
nav ul {
display: flex;
flex-direction: row;
border: 1px solid blue;
list-style-type: none;
justify-content: center;
list-style-position: inside;
margin-left: 0;
padding-left: 0;
}
nav ul li {
padding-top: 0.2em;
padding-right: 0.1rem;
border: 1px solid pink;
margin-left: 0;
padding-left: 0;
}
nav li a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 0.875em;
margin-left: 1em;
margin-right: 1em;
}
<header id="masthead">
<div class="container">
<img src="logo.png" alt="logo png" width="200px" class="logo">
<nav>
<ul>
<li>Home</li>
<li>About Us</li>
<li>Contact Us</li>
<li>About Developers</li>
<li>History</li>
<li>Economy</li>
<li>Why Study in Dublin?</li>
<li>People and Culture</li>
</ul>
</nav>
</div>
</header>

How can I apply CSS to this div class?

I am trying to make an image be 300px width in CSS. I created a div class around the image "mainpic" in HTML, and then in CSS, I did .mainpic and width:300px; but it's not changing sizes. Any ideas why the CSS is not applying to this div class? Thank you and code below!
Here's the HTML (minus head section):
<body>
<ul>
<li>Home</li>
<li>Information</li>
<li>Sources</li>
</ul>
<h1>Katherine Graham </h1>
<h2> Silver Spoon to CEO</p>
Democracy Dies In the Dark
<br>
<div class="mainpic">
<img src="http://t2.gstatic.com/licensed-image?q=tbn:ANd9GcR42mPHUzh3APxp1Q8iK6BiQNns98VuwX9zk2nQvukALjFAc8207NEMfcOES8Qe" alt="Katherine Graham">
<div>
<caption>Katherine Graham</caption>
</body>
Here's the CSS:
h1{
color:red;
font-size: 50px;
text-decoration: underline;
}
h2 {
font-size: 25px;
}
ul li {
display: inline;
background-color:;
margin: 10px;
border-radius: 25%;
border-color:khaki;
padding: 25px;
border: 25px;
width: 90px;
list-style-type: none;
}
body {
background-color: antiquewhite;
}
.mainpic {
width: 300px;
}
You need to specify width for img also, otherwise it would keep its original width.
h1 {
color: red;
font-size: 50px;
text-decoration: underline;
}
h2 {
font-size: 25px;
}
ul li {
display: inline;
background-color: ;
margin: 10px;
border-radius: 25%;
border-color: khaki;
padding: 25px;
border: 25px;
width: 90px;
list-style-type: none;
}
.mainpic {
width: 300px;
}
<ul>
<li>Home</li>
<li>Information</li>
<li>Sources</li>
</ul>
<h1>Katherine Graham </h1>
<h2> Silver Spoon to CEO</p>
Democracy Dies In the Dark
<br>
<div class="mainpic">
<img src="http://t2.gstatic.com/licensed-image?q=tbn:ANd9GcR42mPHUzh3APxp1Q8iK6BiQNns98VuwX9zk2nQvukALjFAc8207NEMfcOES8Qe" alt="Katherine Graham" width="100%">
<div>
<caption>Katherine Graham</caption>
Your container width .mainpic is already taking 300px;
Try to add .mainpic img {width:100%}.
This will work for sure.

How can I stop the right floated nav content from overflowing when the window is resized

Trying to set up a simple 'cheat sheet' of logo and nav bar that I can reuse. I'm having trouble preventing the right floated nav from overflowing into content below.
NB. I'm new to this so I have added borders to all elements to help me see what's happening.
I have tried to add a clear:left (even though I know it should be clear:right as the content has been floated right) to the element proceeding the navigation but that did not work of course!
*{
box-sizing: border-box;
}
header{
display: inline-block;
}
.logo{
background-image: url("logo.png");
background-repeat:no-repeat;
width: 140px;
height: 81px;
margin: 10px;
display: inline-block;
}
nav{
border: 1px solid black;
float: right;
width: auto;
}
ul{
list-style: none;
padding-left: 0;
border: 1px solid red;
vertical-align: middle;
}
li{
display: inline-block;
width: auto;
padding: 20px;
background-color: yellow;
margin-bottom: 5px;
border: 1px solid yellow;
}
.divider{
clear: both;
}
<header>
<div class="logo"></div>
<nav>
<ul>
<li>About</li>
<li>Portfolio</li>
<li>Shopping</li>
<li>Contact Me</li>
</ul>
</nav>
</header>
<div class="divider"></div>
<main>
<h1>The display Property</h1>
So next I tried clear:both and that did not work.
I have also tried to set the nav to display:inline-block but that did not work.
Ideally I would like to solve this without using any pre-provided templates and my just raw code or display:flex.
Thanks in advance :)
Hope this helps.
.nav_bar {
margin: 10px;
padding: 10px;
background-color: #00021a;
color: white;
}
.logo {
display: inline-block;
vertical-align: middle;
width: 7%;
}
.logo img {
height: auto;
width: 50px;
}
.nav {
display: inline-block;
vertical-align: middle;
width: 90%;
}
.nav_container li {
list-style: none;
float: right;
padding: 10px;
}
<head>
<link rel="stylesheet" href="styles.css">
</head>
<div class="nav_bar">
<div class="nav_container">
<div class="logo">
<img class="logo"
src="https://t4.ftcdn.net/jpg/00/71/26/83/240_F_71268376_KIbJvY0SYwlvikWpahjNCv5IBfukykG9.jpg"/>
</div>
<nav class="nav">
<ul>
<li>About</li>
<li>Portfolio</li>
<li>Shopping</li>
<li>Contact Me</li>
</ul>
</nav>
</div>
</div>
Here's the Fiddle

How can I center an image to the right of a navigation bar in html/css?

I'm completely new at coding so I apologize in advance for this question.
I'm trying to centrally align an image to the right of a fixed navigation menu.
Here's my code right now:
HTML:
ul {
list-style-type: none;
float: left;
position: relative;
margin: 0;
padding: 0;
}
li {
padding: 3px;
margin-bottom: 8px;
background-color: #33b5e5;
color: #ffffff;
font-family: "Courier";
}
div.image{
display: block;
display: inline-block;
float: left;
}
<nav>
<ul>
<li>about</li>
<li>cv</li>
<li>adventures</li>
<li>books</li>
<li>blog</li>
<li>quotes</li>
<li>contact</li>
</ul>
</nav>
<div class="image"><img src="vietnam.jpg" alt="" width="450" height="350" /></div>
I want the navigation menu to be fixed to the left, and the image to be to the right of the navigation menu but at the CENTER of the page. here's an image of what I have right now: current homepage. How can I put the image at the center of the page?
Thanks!
If you are trying the centre the whole lot then your nav and div.image should be inline-block to display them side by side. You should then put the lot in a wrapper which you can centre:
section {text-align:center}
nav,
div.image {
display: inline-block;
vertical-align:middle;
}
ul {
list-style-type: none;
position: relative;
margin: 0;
padding: 0;
text-align:left;
}
li {
padding: 3px;
margin-bottom: 8px;
background-color: #33b5e5;
color: #ffffff;
font-family: "Courier";
}
<section>
<nav>
<ul>
<li>about</li>
<li>cv</li>
<li>adventures</li>
<li>books</li>
<li>blog</li>
<li>quotes</li>
<li>contact</li>
</ul>
</nav>
<div class="image"><img src="vietnam.jpg" alt="" width="450" height="350" /></div>
<section>
Updated...
Now that I better understand what you are after (nav on left, image centered in remaining space on the right) it seems that flex-box is the simplest solution:
section {
display:flex;
justify-content: space-between;
align-items: flex-start;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
text-align:left;
}
li {
padding: 3px;
margin-bottom: 8px;
background-color: #33b5e5;
color: #ffffff;
font-family: "Courier";
}
<section>
<nav>
<ul>
<li>about</li>
<li>cv</li>
<li>adventures</li>
<li>books</li>
<li>blog</li>
<li>quotes</li>
<li>contact</li>
</ul>
</nav>
<div class="image"><img src="vietnam.jpg" alt="" width="450" height="350" /></div>
<section>
Attempt 3...
Based on your comments (fyi, you really should try harder to explain your requirements) it sounds like what you want is to centre the image regardless of the nav's position. In the following example I have used margin:auto to centre the .image and position:absolute to fix the nav in the top left. Now the image in centred but the nav may overlap it depending on the viewport width.
nav {display:block; position:absolute;}
ul {
list-style-type: none;
margin: 0;
padding: 0;
text-align:left;
}
li {
padding: 3px;
margin-bottom: 8px;
background-color: #33b5e5;
color: #ffffff;
font-family: "Courier";
}
.image {display:block; width:450px; margin:auto;}
<nav>
<ul>
<li>about</li>
<li>cv</li>
<li>adventures</li>
<li>books</li>
<li>blog</li>
<li>quotes</li>
<li>contact</li>
</ul>
</nav>
<div class="image"><img src="vietnam.jpg" alt="" width="450" height="350" /></div>
you can use your div class if class is not work then use id for div like id="image"
#media All and (max-width: 641px) {
ul {
list-style-type: none;
float: left;
position: relative;
margin: 0;
padding: 0;
}
li {
padding: 3px;
margin-bottom: 8px;
background-color: #33b5e5;
color: #ffffff;
font-family: "Courier";
}
div.image{
padding-top: 25%;
margin-left: 16%;
}
}
#media screen and (min-width: 641px) and (max-width: 800px) {
ul {
list-style-type: none;
float: left;
position: relative;
margin: 0;
padding: 0;
}
li {
padding: 3px;
margin-bottom: 8px;
background-color: #33b5e5;
color: #ffffff;
font-family: "Courier";
}
div.image{
padding-top: 23%;
margin-left: 21%;
}
}
#media screen and (min-width: 801px) and (max-width: 1024px) {
ul {
list-style-type: none;
float: left;
position: relative;
margin: 0;
padding: 0;
}
li {
padding: 3px;
margin-bottom: 8px;
background-color: #33b5e5;
color: #ffffff;
font-family: "Courier";
}
div.image{
padding-top: 18%;
margin-left: 24%;
}
}
#media screen and (min-width: 1025px){
ul {
list-style-type: none;
float: left;
position: relative;
margin: 0;
padding: 0;
}
li {
padding: 3px;
margin-bottom: 8px;
background-color: #33b5e5;
color: #ffffff;
font-family: "Courier";
}
div.image{
padding-top: 13%;
margin-left: 30%;
}
}
}
<nav>
<ul>
<li>about</li>
<li>cv</li>
<li>adventures</li>
<li>books</li>
<li>blog</li>
<li>quotes</li>
<li>contact</li>
</ul>
</nav>
<div class="image"><img src="vietnam.jpg" alt="" width="450" height="350" /></div>
kindly check my codes i'll create for you
.image{
display: block;
text-align: center;
}
.image > img{
background-color: red;
}
You can also check this link for your exact code http://codepen.io/myco27/pen/dNxWWK
You can put the img element into nav and style nav with display:flex, justify-content: space-between See the code snippet
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
padding: 3px;
margin-bottom: 8px;
background-color: #33b5e5;
color: #ffffff;
font-family: "Courier";
}
nav {
display: flex;
justify-content: space-between;
}
<nav>
<ul>
<li>about</li>
<li>cv</li>
<li>adventures</li>
<li>books</li>
<li>blog</li>
<li>quotes</li>
<li>contact</li>
</ul>
<div class="image"><img src="vietnam.jpg" alt="" width="450" height="350" /></div>
</nav>

CSS / HTML Navigation and Logo on same line

I can't figure out how to put them on the same line.
http://codepen.io/anon/pen/dovZdQ
<body>
<div class="navigation-bar">
<div id="navigation-container">
<img src="logo.png">
<ul>
<li>Home</li>
<li>Projects</li>
<li>About</li>
<li>Services</li>
<li>Get in Touch</li>
</ul>
</div>
</div>
</body>
The <ul> is by default a block element, make it inline-block instead:
.navigation-bar ul {
padding: 0px;
margin: 0px;
text-align: center;
display:inline-block;
vertical-align:top;
}
CodePen Demo
Firstly, let's use some semantic HTML.
<nav class="navigation-bar">
<img class="logo" src="logo.png">
<ul>
<li>Home</li>
<li>Projects</li>
<li>About</li>
<li>Services</li>
<li>Get in Touch</li>
</ul>
</nav>
In fact, you can even get away with the more minimalist:
<nav class="navigation-bar">
<img class="logo" src="logo.png">
Home
Projects
About
Services
Get in Touch
</nav>
Then add some CSS:
.navigation-bar {
width: 100%; /* i'm assuming full width */
height: 80px; /* change it to desired width */
background-color: red; /* change to desired color */
}
.logo {
display: inline-block;
vertical-align: top;
width: 50px;
height: 50px;
margin-right: 20px;
margin-top: 15px; /* if you want it vertically middle of the navbar. */
}
.navigation-bar > a {
display: inline-block;
vertical-align: top;
margin-right: 20px;
height: 80px; /* if you want it to take the full height of the bar */
line-height: 80px; /* if you want it vertically middle of the navbar */
}
Obviously, the actual margins, heights and line-heights etc. depend on your design.
Other options are to use tables or floats for layout, but these are generally frowned upon.
Last but not least, I hope you get cured of div-itis.
You need to apply the logo class to the image...then float the ul
Codepen Demo
HTML
<img class="logo" src="http://i.imgur.com/hCrQkJi.png">
CSS
.navigation-bar ul {
padding: 0px;
margin: 0px;
text-align: center;
float: left;
background: white;
}
I'll advise you use CSS Flex.
body {
margin: 0;
padding: 0;
}
#navigation-container {
position: relative;
background-color: #352d2f;
display: flex;
flex-direction: row;
justify-content: space-between;
}
ul {
display: flex;
flex-direction: row;
list-style-type: none;
}
a {
text-decoration: none;
color: black;
font-size: 16px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
padding: 5px 15px;
opacity: 0.7;
}
li {
display: flex;
flex-direction: row;
align-items: center;
}
<head>
<link href="./answer.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="navigation-bar">
<div id="navigation-container">
<img src="https://i.imgur.com/hCrQkJi.png">
<ul>
<li>Home</li>
<li>Projects</li>
<li>About</li>
<li>Services</li>
<li>Get in Touch</li>
</ul>
</div>
</body>
Try this CSS:
body {
margin: 0;
padding: 0;
}
.logo {
float: left;
}
/* ~~ Top Navigation Bar ~~ */
#navigation-container {
width: 1200px;
margin: 0 auto;
height: 70px;
}
.navigation-bar {
background-color: #352d2f;
height: 70px;
width: 100%;
}
#navigation-container img {
float: left;
}
#navigation-container ul {
padding: 0px;
margin: 0px;
text-align: center;
display:inline-block;
}
#navigation-container li {
list-style-type: none;
padding: 0px;
height: 24px;
margin-top: 4px;
margin-bottom: 4px;
display: inline;
}
#navigation-container li a {
color: white;
font-size: 16px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
text-decoration: none;
line-height: 70px;
padding: 5px 15px;
opacity: 0.7;
}
#menu {
float: right;
}
1) you can float the image to the left:
<img style="float:left" src="http://i.imgur.com/hCrQkJi.png">
2)You can use an HTML table to place elements on one line.
Code below
<div class="navigation-bar">
<div id="navigation-container">
<table>
<tr>
<td><img src="http://i.imgur.com/hCrQkJi.png"></td>
<td><ul>
<li>Home</li>
<li>Projects</li>
<li>About</li>
<li>Services</li>
<li>Get in Touch</li>
</ul>
</td></tr></table>
</div>