Copy link to clipboard
Copied
This is the layout I am trying to design:
header
<row1>
<col 1> image xxx <col2> image
<Row2>
<col1> menu <col 2) content
footer
A pretty basic standard layout, however, why is the menu moving up between the space between col1 and col2 of row 1 (marked as XXX.?
Hope this makes sense.
D
Maybe the below would help:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Page Title</title>
<style>
* {
box-sizing: border-box;
}
body {
font-family: Times, "Times New Roman", "serif";
background-color: #FFFFFF;
}
.container {
width: 80%;
max-width: 1024px;
margin: 0 auto;
border: 1px solid #000;
}
.float_left {
float: left;
}
.float_right {
float: right;
}
header h1 {
margin:0;
padding:
...Copy link to clipboard
Copied
Please show us the code.
Copy link to clipboard
Copied
Hi,
Can you try using "Apply Source Formatting" and see if this fixes the issue your are facing? If not then please share your code and the CSS files your are using to format the layout.
Regards,
Niharika Gupta
Copy link to clipboard
Copied
Thank you so much!
Here it is:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Preventive Law Reporter</title>
<link rel="stylesheet" href="stylestest.css">
<link rel="stylesheet" href="js/slicknav.css">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="container">
<header>
<div class="row">
<div class="col">
<h1> PREVENTIVE LAW FOR CANADIAN PROFESSIONALS</h1>
</div>
</div>
<div class="row">
<div class="col1-image"> <img src="images/scales-preventive.gif" alt="Scales of Justice"> </div>
<div class="col2-image"> <img src="images/preventivelawreporter.gif"> </div>
</div>
</header>
<ul id="menu">
<li><a href="#">Elementary & Secondary</a></li>
<li><a href="#">Post-Secondary</a></li>
<li><a href="#">Research Services</a></li>
<li><a href="#">Research Login</a></li>
<li><a href="#">Subscribe </a></li>
<li><a href="#">Renew</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</header>
<main>
<div class="row">
<div class="col-sidebar">
<ul id="mainmenu">
<li><a href="#">Login</a></li>
<li><a href="#">Research Services</a></li>
<li><a href="#">Testimonials</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">Subscribe</a></li>
<li><a href="#">Renew</a></li>
</ul>
</div>
<div class="row">
<div class="col-sidebarbottom">This should be under the blue sidebar but with a white background.
Contact us:<br>
By Email:<br>
<br>
By Phone:<br>
Telephone: <br>
Fax: (<br>
<br>
By Mail:<br>
</div>
</div>
<div class="col-main">MAIN CONTENT should be to the right of the top/bottom sidebars </div>
</div>
</main>
<footer>
<h3>Footer - Preventive Law Reporter</h3>
</footer>
<script src="js/jquery-1.11.3.min.js"></script>
<script src="js/jquery.slicknav.js"></script>
<script>
$(function(){
$('#menu').slicknav();
});
</script>
</div>
</body>
</html>
CSS:
@charset "utf-8";
/* CSS Document */
/*Desktop Global View*/
body {font-family: Times, "Times New Roman", "serif"; background-color: #FFFFFF;}
#container {max-width: 1024px; border: solid; border-color: #000000; border-width: 1px; padding-top: 1%; margin-left: 20%; margin-right: 20%; padding-left: 0%; padding-bottom: 1%; padding-right: 2%; align-content: center; height: inherit;
}
header
{height: 120px; }
h1 {
color: #8ba5ba;
text-align: center;
font-size: 100%;
font-weight: 400;
}
.col1-image {float: left; max-width: 80%; }
.col2-image {float: right; max-width: 80%; }
.row:after { clear:both;}
#menu {
display: none;
}
.slicknav_menu {
display: none;
}
.col-sidebar {
background-color: #8999bb;
width: 100px;
float: left;
}
.col-main {
background-color: #fff;
margin-left: 25px;
float: right;
height: "600px"
}
#mainmenu ul {
margin: 0;
padding: 0;
color: #fff;
text-align: left;
}
#mainmenu li {
font-size: 12px;
list-style-type: none;
color: #fff;
font-family: Times, "Times New Roman", "serif";
line-height: 22px;
text-align: left;
}
#mainmenu li a {
text-decoration: none;
color: #fff;
text-align: left;
}
.row:after { clear:both;}
/*Tablet View*/
@media (max-width: 768px)
{}
/*Mobile View*/
@media (max-width: 400px)
{
.slicknav_menu {
display: block;
}
h1 {
color: #8ba5ba;
text-align: center;
font-size: 60%;
font-weight: 400;}
#mainmenu {
display: none;
}
img {
max-width: 60%;
max-height: 60%;
}
.heading {
color: #8ba5ba;
font-size: 60%;
font-weight: 100;
max-width: 60%;
}
Copy link to clipboard
Copied
Maybe the below would help:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Page Title</title>
<style>
* {
box-sizing: border-box;
}
body {
font-family: Times, "Times New Roman", "serif";
background-color: #FFFFFF;
}
.container {
width: 80%;
max-width: 1024px;
margin: 0 auto;
border: 1px solid #000;
}
.float_left {
float: left;
}
.float_right {
float: right;
}
header h1 {
margin:0;
padding: 30px 0;
font-size: 18px;
color: #92B8DE;
font-weight: 400;
text-align: center;
overflow: hidden;
}
.corporate_logos {
overflow: hidden;
padding: 15px 30px;
}
aside {
float: left;
width: 25%;
background-color: #8999BB;
margin: 0;
padding: 0;
}
.side_menu {
padding: 30px;
}
.side_menu ul {
margin: 0;
padding: 0;
}
.side_menu li {
margin: 0;
padding: 0;
list-style: none;
}
.side_menu a {
text-decoration: none;
color: #fff;
display: block;
padding: 5px 0;
}
.content {
float: left;
width: 75%;
padding: 0 35px;
}
footer {
clear: both;
padding: 10px;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>PREVENT LAW FOR CANADIAN PROFESSIONALS</h1>
<div class="corporate_logos">
<img src="images/scales-preventive.gif" alt="Scales of Justice" class="float_left">
<img src="images/preventivelawreporter.gif" alt="Law Reporter" class="float_right">
</div>
<!-- end corporate_logos -->
<nav class="top_menu">
<ul>
<li><a href="#">Elementary & Secondary</a></li>
<li><a href="#">Post-Secondary</a></li>
<li><a href="#">Research Services</a></li>
<li><a href="#">Research Login</a></li>
<li><a href="#">Subscribe </a></li>
<li><a href="#">Renew</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</nav>
<!-- end top_nav -->
</header>
<!-- end header -->
<div class="main_content_wrapper">
<aside>
<nav class="side_menu">
<ul>
<li><a href="#">Login</a></li>
<li><a href="#">Research Services</a></li>
<li><a href="#">Testimonials</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">Subscribe</a></li>
<li><a href="#">Renew</a></li>
</ul>
</nav>
<!-- end main_menu -->
</aside>
<main class="content">
<h3>MAIN CONTENT should be to the right of the top/bottom sidebars</h3>
</main>
<!-- end content -->
</div>
<!-- end main_content_wrapper -->
<footer>
<h3>Footer - Preventive Law Reporter</h3>
</footer>
<!-- end footer -->
</div>
<!-- end container -->
</body>
</html>
Copy link to clipboard
Copied
Thank you so much, you have been a big help!!!
The part that I am still struggling with is that within the main content wrapper I need another box that falls under the "side menu" blue box It will contain text and has a black border around it. Then the main is across from them both to the right.
There is a "menu" that shows up just for mobile, that works great now.
Here is the original, what I am trying to get it to look like: Education Law - Reporter Elementary & Secondary
Here is where I am now:
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Page Title</title>
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="js/slicknav.css">
<style>
* {
box-sizing: border-box;
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>PREVENTIVE LAW FOR CANADIAN PROFESSIONALS</h1>
<div class="corporate_logos"> <img src="images/scales-preventive.gif" alt="Scales of Justice" class="float_left"> <img src="images/preventivelawreporter.gif" alt="Law Reporter" class="float_right"> </div>
<img src="images/spacer.gif" class="spacer-size">
<!-- end corporate_logos -->
<ul id="menu">
<li><a href="#">Elementary & Secondary</a></li>
<li><a href="#">Post-Secondary</a></li>
<li><a href="#">Research Services</a></li>
<li><a href="#">Research Login</a></li>
<li><a href="#">Subscribe </a></li>
<li><a href="#">Renew</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</header>
<!-- end header -->
<div class="main_content_wrapper">
<aside>
<nav class="side_menu">
<ul>
<li><a href="#">Elementary</a></li>
<li><a href="#">Research Services</a></li>
<li><a href="#">Testimonials</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">Subscribe</a></li>
<li><a href="#">Renew</a></li>
</ul>
</nav>
</aside>
This should be in outlined box with a white background under the blue box.
Contact us:<br>
By Email:<br>
publications@preventivelaw.ca<br>
<br>
By Phone:<br>
Telephone: (403)640-6242<br>
Fax: (403) 640-9911<br>
<br>
By Mail:<br>
Education Law Infosource Ltd.<br>
Box 72038 RPO Glenmore Landing<br>
Calgary, Alberta T2V 5H9 </aside>
<!-- end main_menu -->
<main class="content">
<h3>MAIN CONTENT should be to the right of the top/bottom sidebars</h3>
</main>
<!-- end content -->
</div>
<!-- end main_content_wrapper -->
<footer>
<h3>Footer - Preventive Law Reporter</h3>
</footer>
<script src="js/jquery-1.11.3.min.js"></script>
<script src="js/jquery.slicknav.js"></script>
<script>
$(function(){
$('#menu').slicknav();
});
</script>
<!-- end footer -->
</div>
<!-- end container -->
</body>
</html>
CSS:
@charset "utf-8";
/* CSS Document */
/*Desktop Global View*/
body {
font-family: Times, "Times New Roman", "serif";
background-color: #FFFFFF;
}
.container {
width: 80%;
max-width: 1024px;
margin: 0 auto;
border: 1px solid #000;
}
.slicknav_menu {
display: none;
}
#menu {
display: none;
}
.float_left {
float: left;
margin-left: 20%;
}
.float_right {
float: right;
}
.spacer-size {
width: 100%;
}
header h1 {
margin: 0;
padding: 10px;
0px;
font-size: 16px;
color: #8999BB;
font-weight: 400;
text-align: center;
overflow: hidden;
}
.corporate_logos {
overflow: hidden;
padding-left: 3%;
padding-right: 15%;
padding-top: 0px;
padding-bottom: 2px;
}
aside {
float: left;
width: 20%;
background-color: #8999BB;
margin: 0;
padding: 0;
}
.side_menu {
padding: 30px;
}
.side_menu ul {
margin: 0;
padding: 0;
}
.side_menu li {
margin: 0;
padding: 0;
list-style: none;
}
.side_menu a {
text-decoration: none;
color: #fff;
display: block;
padding: 5px 0;
}
.content {
float: left;
width: 75%;
padding: 0 35px;
}
footer {
clear: both;
padding: 10px;
text-align: center;
}
/*Tablet View*/
@media (max-width: 768px) {
}
/*Mobile View*/
@media (max-width: 400px) {
.slicknav_menu {
display: block;
}
.side_menu {
display: none;
}
.container {
width: 80%;
margin: 0 auto;
border: 0px solid #000;
}
.corporate_logos {
overflow: hidden;
padding: 5px 5px;
}
header h1 {
margin: 0;
padding: 30px 0;
font-size: 12px;
color: #92B8DE;
font-weight: 400;
text-align: center;
overflow: hidden;
}
Copy link to clipboard
Copied
Insert another <div> (see below) 'contact_details' directly AFTER the closing </nav> tag of the 'side_menu'
<div class="contact_details">
<strong>Contact us:</strong><br>
By Email:<br>
xxxxxxxxxxxx@xxxxxxxxxx.xx<br>
<br>
<strong>By Phone:</strong><br>
Telephone: (403)640-6242<br>
Fax: (403) 640-9911<br>
<br>
<strong>By Mail:</strong><br>
Education Law Infosource Ltd.<br>
Box 72038 RPO Glenmore Landing<br>
Calgary, Alberta T2V 5H9
</div>
<!--end contact_details -->
Then move background-color: #8999BB; from the aside css selector to the .side_menu css selector a shown below:
aside {
float: left;
width: 20%;
background-color: #8999BB;
margin: 0;
padding: 0;
}
.side_menu {
padding: 30px;
background-color: #8999BB;
}
Then your can style the contact_details container with the attributes you require.
.contact_details {
border: 1px solid #000;
padding: 15px;
}
Copy link to clipboard
Copied
Awesome, thank you!!!! So basically, by putting a div within the aside, you achieved it! I should have tried that, lol! Learning a lot by trying nevertheless! Enjoy your day!
Copy link to clipboard
Copied
Hi,
I have tried to place the elements as you suggested and the final layout looks like below. I would suggest using tables to place elements on the page, that gives you more control on positioning them as you like.
And the code for this is-
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Preventive Law Reporter</title>
<link href="new.css" rel="stylesheet" type="text/css">
</head>
<body class="column">
<div id="container">
<div id="header">
<centre>
<p id="pagetitle">Preventive Law Reporter</p>
</centre>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tbody><tr>
<td ><img src="images/scales-preventive.gif" alt="Scales of Justice"> </td>
<td><img src="images/scales-preventive.gif" alt="Scales of Justice">
</td>
</tr>
</tbody></table>
<!-- end #header --></div>
<div id="sidebar1">
<table width="200" border="0" cellpadding="0" bgcolor= "#8999bb">
<tbody><tr height="35px">
<td height="35px"><a href="#" target="_self"> Login</a></td>
</tr>
<tr height="35px">
<td height="35px"><a href="#" target="_self"> Research Services</a></td>
</tr>
<tr height="35px">
<td height="35px"><a href="#" target="_self"> Testimonials</a></td>
</tr>
<tr height="35px">
<td height="35px"><a href="#" target="_self"> Links</a></td>
</tr>
<tr height="35px">
<td height="35px"><a href="#" target="_self"> Subscribe</a></td>
</tr>
<tr height="35px">
<td height="35px"><a href="#" target="_self"> Renew</a></td>
</tr>
</tbody></table>
<br>
<table width="200" border="1" >
<tbody><tr>
<td><span class="editor">Contact Us:<br>
Email:<br>
Telephone:<br>
Fax:<br>
Mail:<br><br>
</span></td>
</tr>
</tbody></table>
</div>
<div id="mainContent">
<table border="0" width="680px" cellpadding="5" cellspacing="0">
<tbody><tr>
<td valign="top"><br>
<span class="content">Main content
</span>
</td>
</tr></tbody></table>
<!-- end #mainContent -->
</div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat">
<div id="footer">
<p> Footer - Preventive Law Reporter</p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body></html>
CSS:
@charset "utf-8";
body {
font: 100% Times;
background: #fff;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
}
a:link {
color: #FFF;
text-decoration: none;
}
.column #container {
width: 900px; /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
}
.column #header {
background: #fff;
padding: 0 ; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */
}
.column #sidebar1 {
float: left; /* since this element is floated, a width must be given */
width: 200px; /* the actual width of this div, in standards-compliant browsers, or standards mode in Internet Explorer will include the padding and border in addition to the width */
padding: 0;
color: #FFF;
}
.column #sidebar1 table tr td {
margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
padding: 0px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
font-family: "Times New Roman", Times, serif;
font-size: 14px;
font-weight: bold;
}
.column #mainContent {
margin: 0 0px 0 0px; /* the left margin on this div element creates the column down the left side of the page - no matter how much content the sidebar1 div contains, the column space will remain. You can remove this margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends. */
padding: 0px 0px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
.content {
font-family: "Times New Roman", Times, serif;
font-size: 14px;
font-style: normal;
color: #000;
text-align: left;
}
.column #footer #pagetitle{
padding: 0 10px 0 20px; /* this padding matches the left alignment of the elements in the divs that appear above it. */
background:#fff;
}
#pagetitle{
margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
font-family: "Times New Roman", Times, serif;
font-size: large;
font-weight: bold;
text-align: center;
}
.column #footer p {
margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
font-family: "Times New Roman", Times, serif;
font-size: small;
font-weight: bold;
text-align: center;
}
.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
.editor {
font-family: "Times New Roman", Times, serif;
font-size: 9px;
font-style: normal;
color: #000;
}
Regards,
Niharika Gupta
Copy link to clipboard
Copied
'I would suggest using tables to place elements on the page, that gives you more control on positioning them as you like.'
Suggest using tables for layout, really? - what century do you come from. That's just plain awful advice in this day and age.
Copy link to clipboard
Copied
According to the Consortium 4.9 Tabular data — HTML5
table
element represents data with more than one dimension, in the form of a table.Copy link to clipboard
Copied
I would suggest using tables to place elements on the page...
Oh my gosh!
Please DO NOT use tables for layouts except for HTML emails.
Modern web sites are built with HTML5 code and CSS layouts now.
Nancy
Copy link to clipboard
Copied
I am slowly learning responsive web design, but I did know NOT to use tables! That was the old coding I was moving away from lol! The learning curve is certainly assisted with having great advice from this site!!! Thank you!
Copy link to clipboard
Copied
Reply #4 is as close as you will get as a correct answer.