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

Unveiling and Shifting Among Concealed HTML Forms

After going through numerous tickets with similar questions, I still can't seem to achieve what I want. So, I have no choice but to ask this question myself. I currently have an HTML page with 2 forms and 2 buttons. Both forms are initially hidden us ...

Issue encountered while trying to modify the color of a placeholder

Whenever I attempt to modify the placeholder's color: ::-webkit-input-placeholder { /* WebKit, Blink, Edge */ color: #909; } :-moz-placeholder { /* Mozilla Firefox 4 to 18 */ color: #909; opacity: 1; } : ...

Why am I not receiving any results from the communication between JavaScript and PHP using an HTTP GET request?

Currently, I have a small JavaScript program running within an HTML5 canvas and included a HTTP GET request function in my JavaScript code. The function itself is functioning properly as I tested it with multiple examples from the internet, all of which wo ...

Utilizing Beautifulsoup to extract elements from Selenium

When utilizing BeautifulSoup with Selenium, I usually start by parsing the entire page using soup = BeautifulSoup(driver.page_source). But what if I only want to parse a specific element from Selenium in BeautifulSoup? If you try the following code snipp ...

Ways to manipulate the placement of angular material 2 sidenav content to the bottom

I have been experimenting with various methods in CSS to override the existing side nav component in Angular Material 2. mat-sidenav-container { background: white; bottom: 0px !important; /* <---- no success */ } mat-sidenav { width: 300px; ...

A problem encountered in specific JavaScript code

As a newcomer to JavaScript, I have encountered an issue while trying to run this script: <html> <head> <title>Exploring javascript functionalities</title> </head> <body> <p id="demo">I ...

Saving Data in an Angular Material Table: A How-to Guide

I have a basic angular material table and I am looking for a way to save the data displayed in each row when a button is clicked. Is it possible to save each row of data as an object and push it to an array? If so, how can I achieve this? <div class=& ...

Images in CSS accordion not displaying correctly in WordPress website

It seems like I am overlooking a simple solution here, but it's escaping me. I'm attempting to make a CSS accordion function where each section links to a page. If you want to view the source refer to this link Here is my test site URL: this l ...

Guide on navigating to a specific page with ngx-bootstrap pagination

Is there a way to navigate to a specific page using ngx-bootstrap pagination by entering the page number into an input field? Check out this code snippet: ***Template:*** <div class="row"> <div class="col-xs-12 col-12"> ...

Tips for creating a dynamically responsive eye icon placement

When the screen width is less than 991px, the content is centered but the eye icon that is absolutely positioned goes off-center. This issue only occurs on devices with a small or medium screen size. The reason for using absolute positioning on the icon i ...

The iPhone header position switches when an HTML5 input type number is selected

I am currently working on a project that involves jQuery Mobile and PhoneGap. One issue I am encountering is when using the iPhone version, the header position changes when I click on an input type number. NOTE: When I focus on the input type number in my ...

Changing the position from fixed to static

It's strange, but for some reason when I attempt to apply position:fixed using jQuery: $('#footer').css('cssText', 'position:fixed !important;'); to my footer, the result on the page is different: <div id="footer" ...

Remove the 'name' attribute from the input tag within the URL

Is there a way to make the server update the URL format to localhost:3000/userinput instead of localhost:3000/?name=userinput when submitting a name? Any suggestions would be greatly appreciated. Thank you in advance. ExpressJs FILE <!DOCTYPE html> ...

Navigating an indefinite amount of state variables in React.js: A comprehensive guide

Receiving data from the server with an unknown number of items in the API leads me to utilize the map method in HTML for rendering. Below is the return section: if (loading) { return ( <div> <div> <Header /> ...

retrieve the timestamp when a user initiates a keystroke

Seeking assistance from the community as I have been struggling with a problem for days now. Despite searching on Google and Stack Overflow, I haven't found a solution that works for me. My web application features an analog clock, and I need to capt ...

When using the resize property in monaco-editor, it may result in editor popups being obscured or

My current task involves utilizing the deltaDecorations method to display errors in my editor. Feel free to check out my code here: https://gist.github.com/dinager/41578bd658b60cc912a6023f80431810 Below is the output: I am currently attempting to in ...

Issue with random pages where global header.php is not showing a specific image

I'm currently revamping a website that was originally developed using codeigniter. The backend is quite chaotic with no clear identifiers for anything. I recently updated the banner in the header.php file, adjusting the style to suit the requirements. ...

The Boostrap background is failing to display as expected in CSS, and the `position: fixed` property is

I am struggling to add an extra class within the div class= "container-fluid" in order to set a background with a fixed position, but it doesn't seem to work. The only way I can add a background-image is directly in the HTML. Why is that? Another is ...

Setting Image Height with CSS

I have a div with a height of 105px. The image inside the div is 359px tall. How can I adjust the div's size to prevent cutting off the image and ensure it displays in full height? Thank you for your help! ...

First-character styling not applying to ID in CSS

My CSS :first-letter selector is effective on all p elements, however when applied to a span with the id #fletter, it doesn't seem to work... #fletter span:first-letter { font-weight: 600; font-size: 25px; } <span id="fletter"> The : ...