Issues with Vertical Alignment and Navigation

Link: Please resize the browser to mobile view.

Issue with Header: I am facing alignment issues in the header. The elements do not seem to be aligned properly at the center of the header. The Android logo is aligned, but the text and dash image are not. :/

Navigation Problems: The Navigation Drop Down works when hovering over "ALL," but the links after Link 2 are hidden behind an image. I attempted to use z-index for a solution, but it did not work.

Content Area Troubles: Another problem arises with vertical alignment. There appears to be extra space at the bottom of the content section.

Index.html

<html lang="en">

<head>

    <meta charset="utf-8">

    <title></title>

    <meta name="viewport" content="width=device-width; initial-scale=1; maximum-scale=1">

        <link rel="stylesheet" href="css/styled.css">

    <!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->

</head>

<body>

    <header>    
            <div class="image_carousel">
            <img src="images/menu.png" style="width: 15px; height: 22px;" />
            <img src="images/android_icon.png" style="margin-top: 10px; width: 26px; height: 46px;" />
        <div class="nav">
            <a href="#" id="menu-icon">ALL</a>

            <ul>
                <li><a href="#">LINK1</a></li>
                <li><a href="#">LINK2</a></li>
                <li><a href="#">LINK3</a></li>
                <li><a href="#">LINK4</a></li>
                <li><a href="#">LINK5</a></li>
            </ul>

        </div>
        </div>
        <div class="clearfix"></div>
    </header>

    <section>
        <img src="images/headerimg.jpg" />

        <div class="bround">
        <img src="images/logo.jpg" class="imgleft" width="75px" />
        <b>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis feugiat quam vitae mauris lacinia, id tincidunt eros lobortis.</b> 
        <p class="bauthor">Olajide Olaolorun | <a href="">1 Comment</a></p>
           </div>
        <div class="clearfix"></div>

        <div class="bround">
        <img src="images/logo.jpg" class="imgleft" />
        <b>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis feugiat quam vitae mauris lacinia, id tincidunt eros lobortis.</b>
        <p class="bauthor">Olajide Olaolorun | <a href="">1 Comment</a></p>
           </div>
        <div class="clearfix"></div>


    </section>

    <footer>

        <p>Copyright Confidential</p>

    </footer>

</body>

</html>

CSS

img {

    width: 100%;

}

header {

    background: #83aa01;
    width: 100%;
    height: 76px;
    /*position: fixed;*/
    top: 0;
    left: 0;
    vertical-align:middle;

}

.image_carousel {
    padding: 5px 0 1px 1px;
    vertical-align: middle;
    text-align: left;
}

.image_carousel img {
    border: 0px;
    padding: 0px;
    margin: 0px;
    display: inline-block;
    vertical-align: middle;
    bottom:0px;
}

.clearfix {
    float: none;
    clear: both;
}

div.bround {
background-color: #FFF;
color: #000;
padding: 20px;
margin-top: 10px;
margin-right: 0px;
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;

}

img.imgleft {
    position:relative; 
    float: left;
    margin: 0px 5px 5px 0px; 
    width: 60px;
}

.bauthor {
color: #D3D3D3;
}

.bauthor a {
color: #83aa01;
}



#menu-icon {

    display: hidden;
    width: 40px;
    height: 40px;
    font-size: 20px;
}

div.nav {
    border: 0px;
    padding: 0px;
    margin: 0px;
    display: inline-block;
    vertical-align: middle;
    bottom:0px;
    color: #FFF;


}


    div.nav ul, div.nav:active ul { 

        display: none;
        position: absolute;
        padding: 0px;
        background: #444;
        color: #FFF;
        top: 50px;
        width: 20%;
        border-radius: 4px 0 4px 4px;

    }

    div.nav li {

        text-align: center;
        width: 100%;
        padding: 5px 0;
        margin: 0px;
        border-bottom: 1px dotted #FFF;
        z-index:1000;
    }

    div.nav:hover ul {

        display: block;

    }

div.nav ul, div.nav a { 

        color: #FFF;
        font-size: 17px;
        font-weight: normal;
        letter-spacing:2px;

}


ul {

    list-style: none;

}

li {

    display: inline-block;
    float: left;
    padding: 10px

}

- Seeking Assistance!

Appreciate your help.

Answer №1

When styling your Header section: adjust the padding-top value of your .image_carousel class to 15px and eliminate any margin-top applied to your android icon. Your CSS should resemble this:

.image_carousel {
padding: 15px 0 1px 1px;
vertical-align: middle;
text-align: left;
}

Regarding the Content Area: It seems you have set a margin-bottom :20px for your p tag, please remove that styling.

Answer №2

Concerning the Navigation issue, an adjustment needs to be made by adding z-index for the dropdown menu. To resolve this, update your CSS as shown below:

div.nav ul, div.nav a
{
color:#fff;
font-size:17px;
font-weight:normal;
letter-spacing:2px;
z-index:10;
}

In terms of the Content Area padding, it is being applied by the following class:

section
{
 margin:80px auto 40px;
 max-width:980px;
 position:relative;
 padding:20px;
}

If you eliminate the margin bottom 40px, it will function properly on mobile devices. However, the drawback is that there may not be enough space on larger screens. To address this, you can utilize a media query and apply this class exclusively to mobile versions.

 @media all and (max-width: 399px)
{
  section
  {
    margin-bottom:0px;
  }
}

Answer №3

This is a test of copying CSS code for display purposes.

header {
background: none repeat scroll 0 0 #83AA01;
height: 76px;
position: relative;
width: 100%;
z-index: 10;
}
.image_carousel {
text-align: center;
vertical-align: middle;
}
.image_carousel img, .image_carousel > .nav {
border: 1px solid #DDDDDD;
display: inline-block;
height: 74px;
line-height: 74px;
padding: 0 30px;
position: relative;
vertical-align: middle;
}
 .image_carousel > .nav:hover {
   background-color: #FF0000;
}
.image_carousel > .nav ul li {
   line-height: normal;
 }
.clearfix {
  clear: both;
  float: none;
 }
div.bround {
   background-color: #FFFFFF;
   border-radius: 15px;
   color: #000000;
   margin-right: 0;
   padding: 20px;
}
img.imgleft {
   float: left;
   margin: 0 5px 5px 0;
   position: relative;
   width: 60px;
}
.bauthor {
  color: #D3D3D3;
}
.bauthor a {
  color: #83AA01;
  }
  #menu-icon {
    display: inline-block;
   font-size: 20px;
   height: 40px;
   width: 40px;
  }
   div.nav ul, div.nav:active ul {
   background: none repeat scroll 0 0 #444444;
  border-radius: 4px 0 4px 4px;
   color: #FFFFFF;
   display: none;
  left: 0;
   padding: 0;
   position: absolute;
  width: 100px;
  margin-top:30px;
}
 div.nav li {
   border-bottom: 1px dotted #FFFFFF;
   margin: 0;
   padding: 5px 0;

   text-align: center;
   width: 100%;
    z-index: 1000;
}
 div.nav li:hover{
    background-color:red;
 }
 div.nav:hover ul {
     display: block;
     top: 43px;
 }
 div.nav ul, div.nav a {
     color: #FFFFFF;
     font-size: 17px;
     font-weight: normal;
      letter-spacing: 2px;
}
ul {
     list-style: none outside none;
 }
li {
    display: inline-block;
    float: left;
    padding: 10px;
 }

 //yes test html 

 <header>    
        <div class="image_carousel">
        <img src="images/menu.png" />
        <img src="images/android_icon.png" />
    <div class="nav">
        <a href="#" id="menu-icon">ALL</a>

        <ul>
            <li><a href="#">LINK1</a></li>
            <li><a href="#">LINK2</a></li>
            <li><a href="#">LINK3</a></li>
            <li><a href="#">LINK4</a></li>
            <li><a href="#">LINK5</a></li>
        </ul>

    </div>
    </div>
    <div class="clearfix"></div>
</header>

<section>
    <img src="images/headerimg.jpg" />

    <div class="bround">
    <img src="images/logo.jpg" class="imgleft" width="75px" />
    <b>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis feugiat quam vitae mauris lacinia, id tincidunt eros lobortis.</b> 
    <p class="bauthor">Olajide Olaolorun | <a href="">1 Comment</a></p>
       </div>
    <div class="clearfix"></div>

    <div class="bround">
    <img src="images/logo.jpg" class="imgleft" />
    <b>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis feugiat quam vitae mauris lacinia, id tincidunt eros lobortis.</b>
    <p class="bauthor">Olajide Olaolorun | <a href="">1 Comment</a></p>
       </div>
    <div class="clearfix"></div>


</section>

<footer>

    <p>Copyright Confidential</p>

</footer>

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

How can I ensure that my content stays fixed at the bottom of a scrolling div in Material UI React?

I have developed a React JS component using Material UI that includes a chat input feature. However, I am facing an issue where the width of the chat input is always half the screen size on desktop or mobile devices. When I try to change the width to 100%, ...

Executing a script for every row in a table using Python and Selenium

As a newcomer to Python and Selenium, I have been struggling with a specific task for days now. Despite my efforts to search and experiment, I find myself completely stuck. My goal is to access sales records within a table that contains information about ...

Exploring Selenium WebDriver: Manipulating Table Elements and Iterating Through Rows

Is there a more efficient way to iterate through tables row by row without using Absolute Xpath? In my test case, I need to search for specific data in each row. This was the previous logic of my code: private static int iRow; WebElement sWorkUnitRows = ...

Is there a way to adjust the padding of html and body elements to 0 in Vue.js without interfering with the styling of bootstrap

In my Vuejs project, I am designing a bootstrap navbar that has left and right margin spacing, even though I have not added any body or html padding. When I navigate to the welcome.blade.php file and set the body and html padding to 0 as shown below: *{ ...

What is the impact of a floated element on vertical spacing?

I have come across an article discussing the usage of CSS, but I am puzzled as to why image number four is not positioned below image number one. Instead, it appears below image number three. Can someone please explain this to me? Here is the HTML code sni ...

The PNG logo will display with white borders when viewed on Internet Explorer 9

My current project involves developing an asp.net mvc web application. In the upper top navigation bar, we have a blue area where I am trying to display our logo using the code snippet below: <a class="brand" href="~/Home/Index/"> <img alt="Group ...

Trouble linking HTML, Javascript, and CSS - seeking help to get them working properly

Hey there! I'm currently trying to transfer my project from Codepen at here to repl.it (This project) which you can find at this link. Don't forget to click run after checking it out! The code is working perfectly fine on Brackets with the same ...

How can progress bars be animated using CSS or JavaScript?

I am currently working on creating a progress bar animation, but I'm unsure whether to use CSS or JS. Can anyone provide insight on how this effect was achieved here? I am hoping to replicate it. Does anyone know if this is the code they used? I&apos ...

shard: the dropdown menu can be interacted with by clicking, but the options

Having trouble selecting an item from a dropdown menu on a modal using splinter. Despite the dropdown being visible and clickable, the selection is failing unexpectedly. (Pdb) dropdown = next(i for i in my_browser.find_by_xpath('//select[@name="exist ...

Retrieving information from a server within several sections of a Flask application

Currently working on a project with Python using Flask and Jinja2, I am exploring ways to integrate a sidebar. Within the HTML pages, there is this snippet: {% include "sidebar.html" %} My objective for the sidebar file is to showcase a section highlight ...

Z-Index not functioning as expected

I've been trying to position my <h1> header on top of a light div with a background image called light.png. I used Z-index to stack them and added position:relative, but for some reason, the <h1> is not showing above the <div class=ligh ...

The footer is not displaying the background image properly

Currently in the process of creating my website. I've successfully added my banner and footer, but unfortunately, I'm facing an issue with the background. It seems to not be stretching out properly, leaving some empty white space. Click here to ...

In what ways can you toggle the visibility of table rows and data dynamically with the onchange event in HTML?

I'm dealing with an HTML code that can dynamically change table data based on user selection. Here's the snippet of my HTML code: Select an option: <select name='set' id="set" class="selectpicker" onchange='displayFields(this. ...

Implementing a full-width search bar within the Bootstrap navbar

I'm trying to create a navbar using Bootstrap 3.7.7 with a logo on the left, links on the right in two rows, and a large search bar in the center. I've managed to align the logo and links correctly, but I'm struggling with sizing the search ...

Is it feasible to customize the icon for the expand/collapse button in the header of jqGrid?

To begin, let me provide some context. In my view, I have 2 or more grids (jqgrid) and I aim to insert an "X" into the expand/collapse button. After several attempts, I successfully added the "X" icon to all grids using this code: .ui-icon-circle-trian ...

Words placed in the middle of the picture

<div> <img style="vertical-align:middle" src="https://placehold.it/60x60"> <span style="">New Product</span> </div> I require this specific layout to be responsive. Could you please provide instructions on achieving this? ...

Having trouble accessing the templateUrl for HTML in Angular version 1.6

I am currently working on a basic Angular 1.6 web application. Although I have created a state for the URL "/", it seems that Angular is unable to locate the file for some reason. The folder structure looks like this: https://i.stack.imgur.com/2p6bP.png ...

How to locate the nearest parent link containing a specific attribute using jQuery

I am trying to locate the nearest link with the attribute findme from a child element .startpoint. Here is the structure: <ul> <li><a href="#">Point one</a></li> <li><a href="#" data-findme="yipi">Point tw ...

Warning: Fastclick alerting about an ignored touchstart cancellation

Having an issue with a double popup situation where the second popup contains selectable fields. Below is the code snippet I am using to display the second popup: $("#select1").click(function(e) { e.stopPropagation(); var tmplData = { string:[& ...

What would cause this to result in a blank array?

I have a main component that contains multiple sub-components, which I navigate between by clicking on different elements. These sub-components are all Vue files. What I am trying to achieve is to dynamically highlight the active component when it is bein ...