html5 aside along with navigation

Check out this snippet of my html code:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>European Networking</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<link href="css/fonts.css" rel="stylesheet" type="text/css">
</head>

<body>
<header id="container"></header>

<div id="main">

<header id="header">
                <section id="logo"><img src="images/logo.png" /></section>
                <section id="search">
                    <table cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td>
                                <select class="s1"> <option>All Categories</option>
                                    <option>WOMEN'S ATHLETIC WEAR</option>
                                    <option>WOMEN'S SOCKS</option>
                                    <option>WOMEN'S UNDERWEAR/BOXERS</option>
                                    <option>WOMEN'S PAJAMAS/HOME ATTIRE</option>
                                    <option>WOMEN'S LEGGINGS</option>
                                </select>
                            </td>
                            <td>
                                <input type="text" class="t1" />
                            </td>
                            <td>
                                <input type="button" class="b1" />
                            </td>
                        </tr>
                    </table>
                </section>
</header>

<nav id="lnav"></nav>

<nav id="mnav"> </nav>

</div>
<footer id="foot">

</footer>

</body>
</html>

This is the CSS used:

body{
    margin: 0px; padding: 0px;  
    background-color: #eceeed;  
    font-family: Segoe UI, Arial, Helvetica, sans-serif;
    color: #4e5452;
}

.t1 {
    font-family:inherit;
    margin-left:3px;
    padding-left:5px;
    height: 30px; 
    width: 260px;   
    border: 0px;
    border-left: 1px solid rgba(255, 0, 0, .1);
    outline:0px;
}
.s1 {
    font-family:inherit;
    margin-left: 2px;
    height: 40px; 
    width: 190px;     
    border: 0 !important;  
    -webkit-appearance: none;  
    -moz-appearance: none;  
    background: url('../images/select.png') no-repeat; 
    background-position: 170px 12px;  
    width: 190px; 
    text-indent: 0.01px; 
    text-overflow: "";  
}

.b1{
border:0px;
width:40px;
height:40px;
background-image: url(../images/search-button.jpg);
}
#container {
    background-image: url(../images/bg-horizonal-bar.jpg);
    background-repeat: repeat-x;
    height: 60px;
    width: auto;
}

#header {
    height:140px;
    width: 1000px auto;
    clear:both;
    }

#logo{
    float:left;
}

#search{
    width:500px;
    height:40px;
    margin-top:50px;
    float:right;
    background-color:#fff;
    overflow:hidden;    
    border: solid 1px #E5E5E5;
    outline: 0;
    background: -webkit-gradient(linear, left top, left 2, from(#FFFFFF), color-stop(4%, #EEEEEE), to(#FFFFFF));
    background: -moz-linear-gradient(top, #FFFFFF, #EEEEEE 1px, #FFFFFF 2px);
    box-shadow: rgba(0, 0, 0, 0.5) 0 0 5px;
    -moz-box-shadow: rgba(0, 0, 0, 0.5) 0 0 5px;
    -webkit-box-shadow: rgba(0, 0, 0, 0.5) 0 0 5px;
}

#main{
    width:1000px;
    margin: 0px auto 0px auto;
}

#lnav{
    width:200px;
    height:45px;
    background-color:#000;
    border-bottom: 5px solid #c40100;
    border-bottom-left-radius: 10px;
    -webkit-border-bottom-left-radius: 10px;
    -khtml-border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    -webkit-border-bottom-right-radius: 10px;
    -khtml-border-bottom-right-radius: 10px;
}

#mnav{
    margin-left:10px;
    height:45px;
    width: 790px;
    background-color:#000;
    border-bottom: 5px solid #c40100;
    border-bottom-left-radius: 10px;
    -webkit-border-bottom-left-radius: 10px;
    -khtml-border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    -webkit-border-bottom-right-radius: 10px;
    -khtml-border-bottom-right-radius: 10px;


}

The issue is with aligning the nav items horizontally, I've attempted various methods such as using float left and right without success. I also tried adding clear codes and changing "nav" to "div". Do you think it's an HTML or CSS problem? What additional CSS code should be applied to lnav and mnav for proper alignment?

I would appreciate any assistance. Thank you.

Answer №1

JSFiddle - DEMO or Fiddle SHOW

Solution 2: Implementing float: right; for #mnav and float: left; for #lnav, check out the DEMO or SHOW

To properly align your elements, apply float: left; to both #mnav and #lnav. Also ensure that you set a fixed width of 1000px; for your #main container before utilizing float.

CSS:

Your CSS styles here...

HTML:

Your HTML code here...

Answer №2

To create space for the Right navigation and reduce its width to fit in, set #lnav and #mnav to have 'display:inline-block'.

Check out this demo with display:inline-block and reduced right nav width: http://jsfiddle.net/adarshkr/kyfztxht/2/

CSS

#lnav{
width: 200px;
height: 45px;
background-color: #000;
border-bottom: 5px solid #c40100;
border-bottom-left-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
-khtml-border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
-webkit-border-bottom-right-radius: 10px;
-khtml-border-bottom-right-radius: 10px;
display: inline-block;
}

#mnav {
margin-left: 10px;
height: 45px;
width: 770px;
background-color: #000;
border-bottom: 5px solid #c40100;
border-bottom-left-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
-khtml-border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
-webkit-border-bottom-right-radius: 10px;
-khtml-border-bottom-right-radius: 10px;
display: inline-block;
}

Alternatively, you can float the navigation elements and enclose them within a div while using clearfix.

See the float example here: http://jsfiddle.net/adarshkr/p717orum/

<div class="navigation cf">
   <nav id="lnav"></nav>

   <nav id="mnav"> </nav>

 </div>

Add the following clearfix code to your CSS:

.cf:after,
.cf:before {
    content: '';
    display: table;
}
.cf:after {
    clear: both;
}
.cf {
    zoom: 1;
}
#lnav{
width: 200px;
height: 45px;
background-color: #000;
border-bottom: 5px solid #c40100;
border-bottom-left-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
-khtml-border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
-webkit-border-bottom-right-radius: 10px;
-khtml-border-bottom-right-radius: 10px;
float:left;
}

#mnav {
margin-left: 10px;
height: 45px;
width: 770px;
background-color: #000;
border-bottom: 5px solid #c40100;
border-bottom-left-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
-khtml-border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
-webkit-border-bottom-right-radius: 10px;
-khtml-border-bottom-right-radius: 10px;
float:right
}

Remember to use clearfix when floating elements to prevent layout issues, and apply the 'cf' class to the parent element containing floated items like I did with the 'navigation' div.

I hope this information proves helpful for your future projects.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the process for attaching an on-click event listener by utilizing an argument that is passed to a function in JavaScript?

These are the functions I have created: function type(message) { document.getElementById("body").innerHTML="<div id=\"textbox\" class=\"textbox\"></div><div id=\"oc\&q ...

Transferring data from an Excel spreadsheet into a structured table

I am interested in transferring specific columns of data from an excel sheet to an HTML table. My goal is to populate the table based on certain conditions rather than statically inputting fixed cells. For instance, if my excel sheet has columns for Name ...

contrasting ionic and android software development kits

I am interested in developing an android application and have some knowledge about Ionic, which is also used for creating mobile apps. I have more experience with Android development and am curious to understand the distinctions between the two platforms ...

How to eliminate cell borders in a Vaadin table

I recently set up a table in Eclipse using Vaadin for assistance. After some trial and error, I successfully removed the borders of the table with the following line of code: tblResetButton.addStyleName(Reindeer.TABLE_BORDERLESS) ; However, there is sti ...

A combination table featuring both fixed and scrolling columns

I'm struggling with a table design where I want part of it to be fixed and the rest to be scrollable. My goal is to achieve something similar to this example, but within a single table structure. If interested, you can view an example here. I found ...

Customizing CSS according to specific URLs

I have two different domains - one ending with .nl and the other ending with .be. For instance, domain.nl and domain.be. Both domains share a similar overall style, but I want certain elements to have distinct styling depending on whether it is the .nl o ...

Automatically refresh and update HTML content

I've created a temp.php file that generates output in JSON format: [{"Date":"2016-10-25 16:12:30","Temp":"1.00"},{"Date":"2016-10-25 16:24:05","Temp":"1.00"},{"Date":"2017-02-25 23:04:04","Temp":"1.00"},{"Date":"2017-02-25 23:05:34","Temp":"1.00"},{" ...

Submit data in the manner of a curl request

Instead of using a curl command to push a file to a web server, I am attempting to create a simple webpage where I can select the file and submit it. Here is the HTML and JavaScript code I have written for this purpose: <html> <body> <i ...

The html viewport size is altered by the mobile keyboard

One issue that arises when using percentage or viewport unit width and height for the <body> element is that the size of these elements will change when a mobile keyboard is invoked due to an input. I have extensively researched this problem without ...

PHP code $this->item->link within an anchor tag is not functioning properly and is displaying JObject->link instead

Hey, can you help with this quick question? It's driving me crazy! I have a PHP file where I'm pulling in different items like contact details. One of these items is $this->item->link, which displays a perfect URL. All I want to do is make ...

Can the PHP stylesheet import be configured to exclude a specific string?

Can I import a PHP stylesheet named style.php into my HTML document? Is there a way to delete certain strings from style.php, such as <style> tags, before importing it using traditional methods like <link>? ...

ADO fails to fetch data from database when applying a filter based on a variable

Trying to write ADO code that displays data from a database based on user input from an HTML form. The approach was to set the user input as a variable and query the database using this variable, but it's not functioning as expected. Here is the curre ...

Validating Phone Numbers in HTML

Seeking assistance from HTML experts - I need to validate a phone number that includes only the plus sign and numeric values, with a maximum of 13 digits. Also looking for guidance on validating an email address with an "@" symbol and a "." without using ...

How can I dynamically adjust the font size of content in a React Material-UI Button when it's unexpectedly

In my web application project, I have created multiple choice questions where each answer is displayed within a single button: <Button fullWidth={true} variant="contained" onClick={(answer) => this.handleAnswer(this.state.answers[0].tex ...

Crafting web design with media queries to ensure responsiveness

I have been working on creating a responsive webpage. While the header and footer are resizing properly when the browser is reduced in size, the navigation section is not behaving the same way. Currently, shrinking the page is causing the navigation block ...

Issues with the code: $("input[type=checkbox]:checked").each(function() { var checkboxId = $(this).attr("id"); });

When submitting a form, I need to retrieve the IDs of all checked checkboxes. Currently, $(this).id() is causing an error. What is the correct code to obtain the IDs of all checked checkboxes? $("#pmhxform input:checkbox:checked").each(function() { ...

Is it possible for jQuery to execute in a sequential manner?

Below is the code I am working with: https://jsfiddle.net/c4zquo60/1/ CSS: #bg { background-repeat: no-repeat; position: absolute; top:0; bottom:0; left:0; right:0; width:100wh; height:100vh; z-index: -1; opacity: ...

Click on the form to initiate when the action is set to "javascript:void(0)"

I am working on an HTML step form that needs to be submitted after passing validation and ensuring all fields are filled. The form currently has an action controller called register.php, but also includes action="javascript:void(0);" in the HTML form. What ...

Capturing a variety of input values from a form and storing them in an array

I have a form with several input fields like this: <input type="text" name="name[]" value=""> <input type="text" name="name[]" value=""> <input type="text" name="name[]" value=""> I am attempting to submit the form and store those value ...

I am interested in developing a program using Javascript or JQuery that can effectively capture the anchor text within <a></a> link tags

I want to automatically capture the link on my website and create a system where, when users click on a specific link, it opens the captured link in a new tab without requiring browser permission and replaces the current tab with a different link. For exa ...