A really dumb HTML 5 problem. Heeelp...

User 2036243 Photo


Registered User
36 posts

Hi,
I'm rewriting my website, and have run into an odd phenomenon that I simply can't understand. I want to enclose the <header> and <nav> sections in a single container, so that the <footer> will run across and below both. Now this truly isn't rocket science.

However, I simply can't persuade my HTML to do this.
Here's the code.
<!DOCTYPE html>
<html lang="en">
<head>
blabla
</head>
<body>
<div id="main">
<header>
<img class="hdrcent" src="../images/logogpsancv.gif" alt="Picture of our logo" title="Our logo" />
</header>
<nav>
<ul>
<li>Occupancy chart &amp; tarifs</li>
<li>Inside "La Souvigne",</li>
<-- etc -->
</ul>
</nav>
Lorem ipsos
</div>
<footer>
Name, address, phone number etc.
</footer>

</body>
</html>

Here's the relevant CSS (the usual HTML5 reset begins the declaration)

html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,address,cite,code,del,dfn,em,img,ins,q,small,strong,sub,sup,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{border:0;margin:0;padding:0}article,aside,figure,figure img,figcaption,hgroup,footer,header,nav,section,video,object{display:block}a img{border:0}figure{position:relative}figure img{width:100%}

/*
* {
-moz-transition: all 0.6s;
-webkit-transition: all 0.6s cubic-bezier(0,.39,.25,1);
transition: all 0.6s cubic-bezier(0,.39,.25,1);
}*/

body {max-width:100%;
background-color:#E6F0FF;
font-size: 0.8em;
margin:10px;}

#main{border:dashed;
border-color:red;
}
header {
background-color: transparent;
border-style: outset;
border-width: 3px;
width: 80%;
clear: none;
margin-left:auto;
margin-right:auto;
}

img.flag{
clear:none;
float:right;
width:5%;
padding-top:5%;
}

IMG.hdrcent{ display: block;
margin-left: auto;
margin-right: auto;
border:none;
width: 90%;
}

nav {background-color: #99C2FF;
float:left;
width:20%;
font-size: 1em;
font-weight:bold;
font-style:italic;
padding-top:80px;
min-height:550px;}
/*snip more stuff*/
=======
I'd have expected that because division main entirely encloses both the header and the nav sections in the code, the red dashed border, which I only put there to make the limits visible, should also enclose both sections. It doesn't, it just encloses the header!
I'm sure it's me, but I'm blessed if I know why.

All the Best
Ian
User 187934 Photo


Senior Advisor
20,188 posts

Can you share a link?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 271657 Photo


Ambassador
3,816 posts

Ian, if you put the nav in the same section as the header, you won't be able to have it on the left side like you do now.
Do you want a vertical, left nav – or do you want a horizontal nav in the header?

Here's a really easy webpage that looks similar to your layout:

http://www.onlywebpro.com/demo/css/resp … esign.html
(Just switch the sidebar to the left instead of right for your side nav area)
If you right-click-view source, all the code (css and html) is there, just copy/paste into the Editor and have a go at it. ;)
I love deadlines. I like the whooshing sound they make as they fly by. (Douglas Adams)
https://www.callendales.com
User 2036243 Photo


Registered User
36 posts

Eric Rohloff wrote:
Can you share a link?
Sure,

Sorry about the delay, but I wanted to fill in a few more goodies before posting it.
Here you go

I still have to do a but more work to finish responsifying it, but until I understand what's wrong I'm stuffed.
All the Best
Ian
User 187934 Photo


Senior Advisor
20,188 posts

#main {
border: medium dashed red;
display: inline-block;
}
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2036243 Photo


Registered User
36 posts

Brilliant, thanks very much. I must read up on the difference between inline-block, inline and block.

I've just about finished that page. Done the basic responsification. Just got to fiddle around with the flag, which will lead to a french version of the page. That might imply playing with the size of the logo in the narrowest viewports.
All the Best
Ian

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.