I'm working on a project where I need to float the previous and next navigation elements to either side of a blog archive page title (green circles for this example). Sitting inside the green circle will be a span with an SVG background element - so the circle needs to be positioned.
I wanted to keep things semantic, so I've laid out my page (section) header as follows:
<header class="archive-box">
<nav class="archive-nav">
<div class="left-nav">
<a class="icon-bg" href="#" title="">
</a>
</div>
<div class="right-nav">
<a class="icon-bg" href="#" title="">
</a>
</div>
</nav>
<h2>Stuff and Things</h2>
</header>
CSS
.archive-box {
max-width: 900px;
height: 75px;
margin: 50px auto;
border: 1px solid;
position: relative;
}
.archive-nav {
position: absolute;
top: 0;
left: 0;
right: 0;
}
.left-nav {
position: absolute;
left: 0;
}
.right-nav {
position: absolute;
right: 0;
}
.icon-bg {
background-color: #9ccb3b;
border-radius: 50%;
height: 75px;
width: 75px;
position: absolute;
}
h2 {
text-align: center;
}
The right navigation element is going outside of its parent's container. I think it might have something to do with the fact that I've got multiple parent-child absolute elements. Is there another way to do this?
Here's the CodePen
Sometimes you need to have specific order of coding css positions. What i mean is if you paste the whole code and run it, it will be different if you wrote it step by step and saved it. It helped me couple of times when i was learning css.
Also try to put margin:auto in .right-nav and .left-nav
Is this how you want it to be? CodePen. Instead of using position: absolute, I've used float: left and float: right so that the left and the right menu items are positioned on the left and the right side respectively and the title is in the center.
section {
position: relative;
background-color: blue;
color: white;
width: 80%;
margin: auto;
}
article {
background-color: green;
height: 50px;
}
h1 {
color: white;
font-size: 30px;
}
nav {
top: 0;
font-size: 20px;
}
.left {
left: 0;
/* position: absolute; */
color: yellow;
}
.right {
right: 0;
/* position: absolute; */
color: pink;
}
h1 {
text-align: center;
}
.bg {
float: left
}
.bgtwo {
float: right;
}
<section>
<nav>
<div class="bg">
<div class="left">LEFT</div>
</div>
<div class="bgtwo">
<div class="right">RIGHT</div>
</div>
</nav>
<h1>Hello There</h1>
<article>
<p>Here is some stuff about things.</p>
</article>
</section>
Related
In summary, I made a container div (parent) with a position: relative, then added 3 children divs with position: absolute. I am now trying to add another div that is below all of this, i.e. the next section of a website. But now the next div appears under the first main "parent" div. From endless searching on here and google I though a main div with position relative would not destroy the flow, but obviously it did or else I would't be posting.
I now want to have another div outside of the parent so that it will go under this first div and make for a nice, scolling website. Please look at my CSS and help me understand why the absolute elements inside a relative element messed up the flow. (I'm new to CSS, so any pro tips are appreciated!)
Here is an image of the website so you get a feel
*{
margin: 0;
padding: 0;
border: 0;
}
body {
font-family: 'Noto Sans HK', sans-serif;
}
/* Arranging the parent and child elements so
images can overlap */
.child {
top: 0;
}
.child-1 {
position: absolute;
left: 0;
z-index: 100;
}
.child-2 {
position: absolute;
right: 0;
z-index: 1;
}
.child-3 {
position: absolute;
padding-top: 38%;
left: 0;
}
#parent {
position: relative;
height: auto;
}
.hero-text {
position: absolute;
text-align: center;
right: 10vw;
top: 28vw;
z-index: 9;
font-size: 3.5vw;
float: right;
color: white;
}
/* Responsive viewport area,
Logo resize based on the screen size */
#logo_png {
max-width: 25vw;
}
#hero_img {
max-width: 85vw;
}
#green_circle_png {
max-width: 40vw;
}
/* NAV BAR STYLING */
#container {
position: absolute;
z-index: 900;
width: 95%;
margin: 0 auto;
}
nav {
float: right;
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 5vw; /* margin-left obly touches the left margin, not L & R */
padding-top: 25px;
position: relative;
}
nav a {
color: white;
text-decoration: none;
text-transform: uppercase;
font-size: 1.4vw;
}
nav a:hover {
color: black;
}
.p1 {
color: #f5f7ff;
font-size: 10vw;
}
#test {
position: relative;
}
<body>
<div id="parent">
<div class="child child-1">
<h1>
<a href='THIS WILL BE LINK TO HOME PAGE'>
<img id="logo_png" src="C:\Users\rebec\Desktop\LBS WEBSITE\Images\lbs_blue_circle_logo_1500x1500.png" alt="Little Big Scientists"/>
</a>
</h1>
</div>
<div class="child child-2">
<h1>
<img id="hero_img" src="Images/circle_hands_lbsphoto.png" alt="Little Big Scientists"/>
</h1>
</div>
<div class="child child-3">
<h1>
<img id="green_circle_png" src="Images/green_circle_lbswebsite.png" alt="Little Big Scientists"/>
</h1>
</div>
<div class="hero-text">
<p>We’re on a mission to teach,
<br>guide, and empower the next
<br> generation of scientists
</p>
</div>
<!-- Div for Nav Bar-->
<div id="container">
<nav>
<ul>
<li>Mission</li>
<li>About</li>
<li>Events</li>
<li>Donate</li>
<li>Contact</li>
</ul>
</nav>
</div>
</div>
<div id="test">
<h2 class="p1">Inspiring Education</h2>
</div>
<h2 class="p1">HELP MEEEE</h2>
</body>
I don't think there's necessarily anything wrong with using absolute positioning for some elements. The main problem you are experiencing is that because everything inside #parent is absolute positioning #parent collapses and has zero height. If you want to do overlapping circles, absolute positioning is a valid way to do it, but you have to expressly set a height for #parent.
Below is a modified copy of your code. I want to emphasize it is a very rough starting point, and by no means is it complete, but I think it demonstrates some of the things you can do. Even with absolute positioning of the circle elements it is still fairly responsive and it could be made fully responsive by adding appropriate media queries to the css.
*{
margin: 0;
padding: 0;
border: 0;
box-sizing: border-box;
}
body {
font-family: 'Noto Sans HK', sans-serif;
}
/* Arranging the parent and child elements so
images can overlap */
.child {
position: absolute;
}
.child-1 {
top: -75px;
left: -75px;
z-index: 100;
width: 300px;
height: 300px;
max-width: 50vw;
max-height: 50vw;
background: blue;
border-radius: 50%;
}
.child-1 h1 {
position: absolute;
right: 10%;
bottom: 20%;
background: white;
}
.child-2 {
right: -40vw;
top: -50vw;
z-index: 1;
width: 120vw;
height: 120vw;
background: center / contain no-repeat url("./Images/circle_hands_lbsphoto.png"), content-box linear-gradient(lightgray, lightgray);
border-radius: 50%;
}
.child-3 {
top: 60vh;
left: -5vw;
width: 550px;
height: 550px;
max-width: 50vw;
max-height: 50vw;
border-radius: 50%;
background: lightgreen;
}
#parent {
position: relative;
min-height: 100vh;
height: 550px;
width: 100vw;
overflow: hidden;
}
.hero-text {
position: absolute;
text-align: center;
left: 40%;
transform: translateX(-50%);
top: 60%;
z-index: 9;
font-size: 3.5vw;
color: white;
}
/* Responsive viewport area,
Logo resize based on the screen size */
#logo_png {
max-width: 25vw;
}
#hero_img {
max-width: 85vw;
}
#green_circle_png {
max-width: 40vw;
position: absolute;
bottom: 20%;
left: 20%;
}
/* NAV BAR STYLING */
#container {
z-index: 900;
width: 100%;
margin: 0 auto;
position: sticky;
top: 0;
background: #fff;
}
nav {
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 5vw; /* margin-left obly touches the left margin, not L & R */
padding-top: 25px;
position: relative;
}
nav a {
color: black;
text-decoration: none;
text-transform: uppercase;
font-size: 1.4vw;
}
nav a:hover {
color: black;
}
.p1 {
color: #f5f7ff;
font-size: 10vw;
}
#test {
position: relative;
}
<body>
<div id="parent">
<div class="child child-1">
<h1>
<a href='THIS WILL BE LINK TO HOME PAGE'>
<img id="logo_png" src="C:\Users\rebec\Desktop\LBS WEBSITE\Images\lbs_blue_circle_logo_1500x1500.png" alt="Little Big Scientists 1"/>
</a>
</h1>
</div>
<div class="child child-2">
<img id="hero_img" alt="Little Big Scientists 2"/>
<div class="hero-text">
<p>We’re on a mission to teach,
<br>guide, and empower the next
<br> generation of scientists
</p>
</div>
</div>
<div class="child child-3">
<h1>
<img id="green_circle_png" src="Images/green_circle_lbswebsite.png" alt="Little Big Scientists 3"/>
</h1>
</div>
</div>
<!-- Div for Nav Bar-->
<div id="container">
<nav>
<ul>
<li>Mission</li>
<li>About</li>
<li>Events</li>
<li>Donate</li>
<li>Contact</li>
</ul>
</nav>
</div>
<div id="test">
<h2 class="p1">Inspiring Education</h2>
</div>
<h2 class="p1">HELP MEEEE</h2>
</body>
I rarely do html/css stuff so I'm struggling trying to implement what seems like a pretty basic layout. I have a bunch of div elements stacked vertically as well as centered horizontally across my html page. The problems I'm facing are
a) the top div (orange) is slightly wider than the other divs.
b) I want the top (orange) div to be visible even when scrolling, which currently isn't the case.
Actually, in order to make the top div always visible, I set its corresponding class' position attribute to fixed but it doesn't work since I also have other divs, and their position is set to relative. If I remove the relative position on the other divs, the orange div works as expected but the rest of divs are not horizontally centered anymore.
.fiksan {
background-color: orange;
position: fixed;
top: 0;
height: 40px;
}
div {
padding: 10px;
color: white;
width: 60%;
left: 20%;
position: relative;
top: 40px;
}
.naslov {
background-color: lightblue;
text-align: justified;
height: 180px;
position: relative;
}
.elementi {
background-color: blue;
height: 650px;
}
.css_elementi {
background-color: purple;
height: 400px;
position: relative;
}
<div class="fiksan">
</div>
<div class="naslov">
</div>
<div class="elementi">
</div>
<div class="css_elementi">
</div>
This is what it looks like now (when scrolling the top div is covered by other divs, and I don't want that)
position:sticky might be what you look for : see https://css-tricks.com/position-sticky-2/
.fiksan {
background-color: orange;
position: sticky;
top: 0;
height: 40px;
}
div {
padding: 10px;
color: white;
width: 60%;
margin:auto;
}
.naslov {
background-color: lightblue;
text-align: justified;
height: 180px;
}
.elementi {
background-color: blue;
height: 650px;
}
.css_elementi {
background-color: purple;
height: 400px;
}
<div class="fiksan">
</div>
<div class="naslov">
</div>
<div class="elementi">
</div>
<div class="css_elementi">
</div>
I am new to CSS and HTML, and I am working on my final project for school.
I am trying to absolutely position some text "Welcome" to a div I've made. For some reason it won't position in relation to the div, I've looked it over 10 times and can't figure out why.
I want the "Welcome" text to sit at the bottom of the welcome div, however when I put bottom:0px; into the CSS, it doesn't position according to its parent container and instead goes 0px from the top of the whole screen.
Here's the code:
#wrapper {
height: 1000px;
margin: 0 auto;
background-image: url(images/background.jpg);
background-size: 100% 100%;
}
#header {
height: 150px;
position: relative;
background-color: red;
}
#welcome {
position: absolute;
bottom: 0;
width: 420px;
height: 100px;
background-color: green;
}
.w {
height: 150px;
position: absolute;
font-size: 64px;
left: 20px;
bottom: 0px;
color: #fff;
}
<div id="wrapper">
<header id="header">
<div id="welcome">
<p class="w">Welcome</p>
</div>
<nav id="main nav"></nav>
</header>
</div>
You are very close. Take the height away from the .w p tag and remove its margin as well:
#wrapper {
height: 1000px;
margin: 0 auto;
background-image: url(images/background.jpg);
background-size: 100% 100%;
}
#header {
height: 150px;
position: relative;
background-color: red;
}
#welcome {
position: absolute;
bottom: 0;
width: 420px;
height: 100px;
background-color: green;
}
.w {
/*height: 150px;*/
margin: 0;
position: absolute;
font-size: 64px;
left: 20px;
bottom: 0px;
color: #fff;
}
<div id="wrapper">
<header id="header">
<div id="welcome">
<p class="w">Welcome</p>
</div>
<nav id="main nav"></nav>
</header>
</div>
The problem, as CalvinNunes pointed out, is that you have a height set on .w div. And, p elements have margin and line-height values by default. You need to remove the margin and set the line-height to 1 or less (.5 makes the text touch the bottom of the green box).
#wrapper {
height: 1000px;
margin: 0 auto;
background-image: url(images/background.jpg);
background-size: 100% 100%;
position: relative;
}
#header {
height: 150px;
background-color: red;
position: absolute;
width: 100%;
}
#welcome {
position: absolute;
bottom: 0;
width: 420px;
height: 100px;
background-color: green;
}
.w {
position: absolute;
font-size: 64px;
left: 20px;
bottom: 0px;
color: #fff;
margin: 0;
line-height: 1;
}
<div id="wrapper">
<header id="header">
<div id="welcome">
<p class="w">Welcome</p>
</div>
<nav id="main nav">
</nav>
</header>
</div>
<!-- End of wrapper-->
If you use absolute on something, related dom element should be relative, absolute or fixed, depending on your needs.
Also check if your absolute element doesn't have some unneeded margins etc.
But in your usage case i don't think that there is absolute needed. you can use bigger paddings for parent element top. Also this can be achieved using flex-end, which will allow dynamic text input.
I don't even know if this is possible. If you check out the image below, you'll see a purple box and a white box. The white box has a photo of my dog Zuko. I'm trying to keep the right edge of that photo perfectly aligned with the right edge of the purple box behind it. But of course, when you start changing the screen size slightly it is no longer aligned. Is there any way to fix those two divs together so when the screen is adjusted, they adjust together and stay aligned?
I tried fixing them both to absolute, using percentages, but I don't even know if what I'm aiming for is possible.
box1 is the purple box, box2 the white containing the photo.
<html>
<head>
<meta charset="utf-8">
<title>ZUKO</title>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>
<body>
<img id="zuko-title" src="zuko-title.svg" alt="Zuko">
<div id="box1" class="floater"></div>
<div id="box2" class="floater">
<div class="intro-text">
<h3>hi, i'm Zuko the dog.</h3>
</div>
<img id="zuko-bolts" src="zuko-bolts.svg" alt="">
</div>
<div id="box3" class="floater">
<ul>
<li>about</li>
<li>frolicking</li>
<li>my 'rents</li>
<li>stuff</li>
</ul>
</div>
</body>
</html>
.floater {
position: absolute;
}
#box1 {
background-color: #DB7ACC;
width: 74%;
height: 100%;
top: 17%;
left: 15%;
z-index: 1;
}
#box2 {
background-color: #fff;
width: 84%;
height: 100%;
top: 25%;
left: 11%;
z-index: 3;
}
#zuko-bolts {
height: 50%;
float: right;
margin-right: 7.2%;
position: absolute;
}
Place #box2 within box#1.
Since they are both positioned and the child (i.e. #box2) is absolute, we would be able to position #box2 within the confines of #box1.
If we want the right edge of #box2 to be flush with the right edge of #box1, set #box2 right:0; this will work for any edge so top:0; would set the top edge of #box2 to the top edge of #box1, and so on.
If we review the Snippet in Full page mode we'll see that no matter how the viewport (width of screen) changes, #box2 will not only conform in size relative to #box1, it will consistently stay in the same position relative to #box1's borders.
SNIPPET
.floater {
position: absolute;
}
#box1 {
background-color: #DB7ACC;
width: 74%;
height: 100%;
top: 17%;
left: 25%;
z-index: 1;
}
#box2 {
background-color: #fff;
width: 84%;
height: 100%;
top: 25%;
right: 0;
z-index: 3;
background: url(http://news.vet.tufts.edu/wp-content/uploads/national-pet-dental-health-month.jpg)no-repeat;
background-size: contain;
border: 1px dashed #db7acc;
}
#zuko-bolts {
height: 50%;
float: right;
margin-right: 7.2%;
position: absolute;
}
<html>
<head>
<meta charset="utf-8">
<title>ZUKO</title>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>
<body>
<img id="zuko-title" src="zuko-title.svg" alt="Zuko">
<div id="box1" class="floater">
<div id="box2" class="floater"></div>
</div>
<div class="intro-text">
<h3>hi, i'm Zuko the dog.</h3>
</div>
<img id="zuko-bolts" src="zuko-bolts.svg" alt="">
</div>
<div id="box3" class="floater">
<ul>
<li>about
</li>
<li>frolicking
</li>
<li>my 'rents
</li>
<li>stuff
</li>
</ul>
</div>
</body>
</html>
I had a different method than Ed, and it could be that it isn't exactly what you need but if you can explain your what you need I'd be more than happy to help you.
I was having a hard time with your HTML, so I changed it a little bit. Hopefully you can figure out on your own which parts you need to change or add.
I tried to comment the code as completely as I could in case you were having trouble understanding.
body,
html {
height: 100%;
margin: 0;
box-sizing: border-box;
background-color: lightgreen;
/*Makes the height and margin for both the HTML and Body elements 100% of the available height, also removes margins.*/
}
.wrapper.zuko {
/*The wrapper for the stuff so that we don't polute our regular HTML with styles and colors we don't need.*/
position: relative;
/* Makes absolute positioning work as expected for child elements*/
background-color: white;
height: 100%;
/*Make it 100% as tall as its parent*/
width: 80%;
/* but only 80% as wide*/
margin: 50px auto;
/* 50px margin on the top and bottom, automatic padding on the left and right*/
padding-top: 10px;
}
.wrapper.zuko .zuko-title {
position: absolute;
/*Changes how this is positioned with respect to its parent.*/
height: 25px;
/*makes the element 25 pixels high*/
line-height: 50px;
/*Probably not needed, but it was ther*/
font-size: 45px;
/*How big is the title text? Hella.*/
padding-left: 5px;
/* Little bit of padding on the left to ensure it's not right on the border */
top: -25px;
/* positioned 25 pixels above the top border of it's parent */
left: 5%;
/* left by 5%*/
right: 10%;
/* right by 10% */
background-color: #cd00cd;
/*random purple color */
}
.wrapper.zuko .zuko-title .zuko-title-img {
position: absolute;
/*again, changes how this thing is positioned by its parent*/
right: 0;
/* directly on the right edge */
top: 100%;
/* 100% of the elements height from the top edge of the element */
}
.wrapper.zuko .zuko-title .zuko-title-text {
position: absolute;
top: -20px;
/*Twitches the text above the purple border like in image.*/
}
<div class="wrapper zuko">
<div class="zuko-title">
<div class="zuko-title-text">
Zuko
</div>
<img src="http://placehold.it/300x200?text=Zuko" alt="" class="zuko-title-img" />
</div>
<div>Hello
</div>
</div>
There's a lot going on in this question... Here's how I might approach the layout you've asked for. Let me know if you have specific questions.
CODEPEN
For the purple box...
Wrap the image in a container and then use a pseudoelement to create the border.
Example
.image-container {
height: 150%;
margin-right: 10%;
width: 90%;
text-align: right;
position: relative;
}
.image-container::before {
content: '';
display: block;
position: absolute;
top: -50px;
width: 90%;
right: 0;
border-top: 50px solid purple;
}
Full snippet
body {
width: 1200px;
margin: 150px auto 0;
background: lightgreen;
position: relative;
}
.intro-text {
position: relative;
}
.intro-text h3 {
position: absolute;
font-size: 120px;
letter-spacing: 4px;
top: -240px;
left: 120px;
z-index: 5;
font-weight: bold;
font-family: sans-serif;
}
#box2 {
background-color: #fff;
width: 84%;
z-index: 3;
padding-bottom: 150px;
position: relative;
}
#box2::after {
content: " ";
display: block;
height: 0;
clear: both;
}
.image-container {
height: 150%;
margin-right: 10%;
width: 90%;
text-align: right;
position: relative;
}
.image-container::before {
content: '';
display: block;
position: absolute;
top: -50px;
width: 90%;
right: 0;
border-top: 50px solid purple;
}
#zuko-bolts {
width: 40%;
}
#box3 {
/* this menu is strangely coded */
position: absolute;
top: 50px;
left: -150px;
z-index: -1;
}
<img id="zuko-title" src="https://placehold.it/50x50" alt="Zuko">
<div id="box1" class="floater"></div>
<div id="box2" class="floater">
<div class="intro-text">
<h3>ZUKO</h3>
</div>
<div class="image-container">
<img id="zuko-bolts" src="https://placehold.it/50x50" alt="">
</div>
</div>
<div id="box3" class="floater">
<ul>
<li>about
</li>
<li>frolicking
</li>
<li>my 'rents
</li>
<li>stuff
</li>
</ul>
</div>
#zuko-bolts {
position: absolute;
height: 50%;
right: 7.14%;
top: 0;
}
Purple box's right side is 6% more to the right of the white box's right side. Since the image is located inside the white box, you need to find the equal of that 6% screen size distance in a 84% box. So basically, 6x100/84=7.14 approximately.
(Posted on behalf of the OP).
Thanks so much everyone for helping. All I had to do was change height: 50% to width and that made it align like it was supposed to.
I am creating a navbar in my website and I want my logo to show next to my site name within the navigation bar, but it doesn't want to cooperate. In the code below is my html with the image inside of my nav bar.
Below is what my css looks like. I tried all of the different position types and I tried to set the navimage's margin and padding.
.navbar {
width: 100%;
height: 50px;
background-color: #2ecc71;
z-index: 1;
position: absolute;
top: 0;
left: 0;
}
#navtitle {
color: white;
font-family: cursive;
font-size: 25px;
position: relative;
top: 20;
margin-top: 10px;
margin-left: 40px;
}
#navimage {
position: absolute;
margin-top: 0px;
margin-left: 140px;
}
<div class="navbar">
<p id="navtitle">Rainforest</p>
<div class="navimage">
<a>
<img src='http://i.imgur.com/Eqbvkgb.png'>
</a>
</div>
</div>
Any ideas?
The simplest way is to put the image inside your paragraph.
<p id="navtitle"><img src='http://i.imgur.com/Eqbvkgb.png'>Rainforest</p>
Size the image as needed.
Your position: absolute prevents the images from appearing as you want, try removing this and adding display:block so that the elements will appear next to each other. You'll probably want to change the css of your image to make it smaller.
Try something like this. Also the image is larger then 50 px so it automatically goes below the nav bar because it can't fit inside. Also, you have navimage title set to class in your html, but its written as an id in your css. ids are with # and class should be .navimage
.navbar {
width: 100%;
height: 50px;
background-color: #2ecc71;
z-index: 1;
position: absolute;
top: 0;
left: 0;
}
#navtitle {
float: left;
}
.navimage {
float:left;
}
<div class="navbar">
<div id="navtitle"><p>Rainforest</p></div>
<div class="navimage">
<a>
<img src='http://i.imgur.com/Eqbvkgb.png'width="20" height="20">
</a>
</div>
</div>
Concept:
Use of float property.
The Code:
Use float:left; for navbar and its elements.This will allow them to overlap each other.
Use position to position them.
Note: I gave Id to the img itself. It is always easier to manipulate the image directly
.navbar {
width: 100%;
height: 50px;
background-color: #2ecc71;
z-index: 1;
position: absolute;
top: 0;
left: 0;
float:left;
}
#navtitle {
color: white;
font-family: cursive;
font-size: 25px;
position: relative;
top: 20;
margin-top: 10px;
margin-left: 40px;
float: left;
}
#navimage {
position: absolute;
margin-top: 0px;
margin-left: 140px;
float:left;
}
#logoimg{
height: 50px;
position: absolute;
left: 2px;
}
<div class="navbar">
<p id="navtitle">Rainforest</p>
<div class="navimage">
<a>
<img id="logoimg" src='http://i.imgur.com/Eqbvkgb.png'>
</a>
</div>
</div>
You set an absolute positioning of the continer, so you should do in this way:
.navbar {
width: 100%;
background-color: #2ecc71;
z-index: 1;
position: absolute;top:0;left:0;
}
#navtitle {
color: #FFF;
font-family: cursive;
font-size: 25px;
margin-left: 10px;
position: relative;
margin-top:10px;
}
#navimage, img {
display:inline;
float:left;
width:30px;
height:40px;
padding:10px
}
http://jsfiddle.net/u3upgedx/