Website Navigation: A guide to organizing columns and rows for optimal user experience

Just reaching out with a question regarding my coding process.

Currently, I am in the midst of translating the website's navigation design into code. The attached image showcases the navigation layout consisting of 10 rows and 8 columns. Below is a snippet of the code I have written for this.

enter image description here

The issue I am encountering is that the height setting value of 10% is not being applied when there is no text present. I would greatly appreciate guidance on how to rectify this problem.

Furthermore, I must admit that I am not well-versed in coding. Therefore, if possible, could you provide me with a specific code example to address this issue?

Thank you in advance for your assistance.

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
  * {
    box-sizing: border-box;
  }

  body {margin-top: 0; margin-left: 0; margin-right: 0;}

  /* Create four equal columns that floats next to each other */
  .column {
    float: left;
    width: 12.5%;
    padding: 0;
    height: 10%/* Should be removed. Only for demonstration */
  }

  .logo {
    float: left;
    width: 12.5%;
    padding: 0;
    height: 20%/* Should be removed. Only for demonstration */
  }

  .column2 {
    float: right;
    width: 87.5%;
    padding: 0;
    margin: 0;
    height: 10%; /* Should be removed. Only for demonstration */
  }

  /* Clear floats after the columns */
  .row:after {
    content: "";
    display: table;
    clear: both;
    margin-top: 0;
  }
</style>
</head>


<body>

  <div class="row">

    <div class="logo" style="background-color:#aaa;">
      <h2>Column 1</h2>
    </div>

    <div class="column" style="background-color:#bbb;">
      <h2>Column 2</h2>
    </div>

    <div class="column" style="background-color:#ccc;">
      <h2>Column 3</h2>
    </div>

    <div class="column" style="background-color:#ddd;">
      <h2>Column 4</h2>
    </div>

    <div class="column" style="background-color:#ddd;">
      <h2>Column 5</h2>
    </div>

    <div class="column" style="background-color:#ddd;">
      <h2>Column 6</h2>
    </div>

    <div class="column" style="background-color:#ddd;">
      <h2>Column 7</h2>
    </div>

    <div class="column" style="background-color:#ddd;">
      <h2>Column 8</h2>
    </div>

    <div class="column2" style="background-color:#ddd;">
      <h2>Column 8</h2>
    </div>

  </div> 

</body>
</html>

Answer №1

If you're looking to utilize CSS grid, I highly suggest checking out the linked comprehensive guide on CSS grid.

Here's an illustration of how grid can be implemented. NOTE: Modifications have been made to your HTML structure.

.container {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

header {
  display: grid;
  grid-template-columns: 1fr 7fr;
  grid-template-rows: 1fr 1fr;
  grid-template-areas: "logo nav" "logo notice";
}

.logo {
  background: red;
  grid-area: logo;
  padding: 10px;
  text-align: center;
}

nav {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-area: nav;
}

.notice {
  background: blue;
  grid-area: notice;
  padding: 10px;
}

nav a {
  padding: 10px;
  border-right: 1px dashed gray;
  text-align: center;
}

main {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}

main>div {
  padding: 10px;
  border-right: 1px dashed gray;
  border-bottom: 1px dashed gray;
  text-align: center;
}
<div class="container">
    <header>
      <div class="logo">Logo</div>
      <nav>
        <a href="#">About</a>
        <a href="#">Exhibition</a>
        <a href="#">Shop</a>
        <a href="#">&nbsp;</a>
        <a href="#">&nbsp;</a>
        <a href="#">&nbsp;</a>
        <a href="#">En</a>
      </nav>
      <div class="notice">Space for Notice</div>
    </header>
    <main>
      <!-- First Row -->
      <div>A</div>
      <div>B</div>
      <div>C</div>
      <div>D</div>
      <div>E</div>
      <div>F</div>
      <div>G</div>
      <div>H</div>

      <!-- Second Row -->
      <div>A</div>
      <div>B</div>
      <div>C</div>
      <div>D</div>
      <div>E</div>
      <div>F</div>
      <div>G</div>
      <div>H</div>

      <!-- Other Rows Up to 8 -->
    </main>
  </div>

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

``There seems to be an issue with the alignment and vertical placement in both Firefox and IE

I'm currently working on a responsive landing page for a company and running into an issue with the CTA button's position outside of Chrome. It's functioning perfectly in Chrome, resizing as intended: Here is the CSS responsible for this: ...

Incorporating Tabs with HTML, CSS, and jQuery

After searching for a way to enable tab selection on click within my HTML fragment representing a tabbed interface, I was unable to find a solution. I resorted to manually programming it using JavaScript, which did work, but I feel there must be a more p ...

When a page is being redirected using requestdispatcher in a filter, the CSS contents do not seem to be applying correctly

Upon evaluation of the condition, if it fails, I am utilizing a request dispatcher to redirect to another page. The redirection is successful, however, the CSS is not being applied to the new page. What could be causing this issue? public class RolePrivil ...

Conceal and reveal feature for multiple dynamic identifiers simultaneously

After submitting the form, I am dynamically creating buttons. <template name="workflow"> {{#each newaction}} <div class="btn-box" > {{> actioncardsubcontent}} <button type="button" class="cancelsub" >New Action</button&g ...

Retrieve the outer-HTML of an element when it is clicked

I am working on a project to develop a tool for locating xpath, and I am seeking the most efficient and user-friendly method for allowing the user to select the desired element on a webpage. Ideally, this selection should be made with just a single click, ...

Positioning the comments box on Facebook platform allows users to

Need assistance, I recently integrated the Facebook comments box into my Arabic website, but I am facing an issue where the position of the box keeps moving to the left. Here is an example of my website: Could someone please suggest a solution to fix the ...

Validate all JavaScript buttons by binding a click event

I've implemented the JS validation plugin from this source and it's functioning properly. However, it captures all button clicks on the page, including when I click on Back to Home, triggering form validation unnecessarily. I only want the form ...

Can anyone suggest a solution to troubleshoot this issue with CSS Flexbox and absolute positioning?

I'm currently developing a React application featuring flex container cards (referred to as .FilmCard with movie poster backgrounds) within another flex container with flex-wrap. Each card has an item positioned absolutely (an FontAwesome arrow icon). ...

Error encountered during the construction of the dojo due to a CSS syntax

I am currently using version 1.9.3 of dojo, and I have encountered an issue with the css file when trying to build dojo using build.bat. The code in my css file is as follows: @import url("TimeDriverCommon.css"); @import url("DialogCommon.css"); @import ...

Mastering the alignment of Material-UI Menu items

When using the menu and menu item components of material-ui to create a select dropdown menu, I encountered an unusual issue where the dropdown menu always expands to the left side of the box, as shown in the image below: https://i.stack.imgur.com/ykRrp.jp ...

What could be the reason my foreach loop is not being run?

After creating a login form that successfully grants access upon entering the correct email and password, there seems to be an issue. A foreach loop is implemented to test all results, with the assumption of only one account existing. foreach ($result as ...

Modifying Link Hover Colors with CSS and PHP

One of the challenges I am facing is managing a file that contains an array of navigation links. This setup allows me to easily add new links to the navigation menu without manually updating multiple files. However, I am struggling with assigning different ...

Resetting several sticky titles after displaying and hiding elements

Inspired by a popular codepen example, I have successfully implemented sticky titles in my sidebar. However, when integrating these sticky titles with the functionality to show/hide related items on click, I encountered some unexpected issues. The code sni ...

My goal is to develop a table that is both able to be resized and easily repositioned

I've been working on a project to develop an interactive table that can be manipulated, resized, and repositioned within a canvas. The code snippet below shows my attempt at creating this table on the canvas: var canvas = document.getElementById("dra ...

Images within links appear with blue lines underneath them

Currently, I am in the process of adding links to a footer by using <img> tags with SVG images. However, I am encountering an issue where there are small blue lines under the icons. After searching online, it seems that you need to add this CSS code: ...

Interactive tool for crafting dynamic web experiences

I am in the process of developing a straightforward hosting website for my projects. However, I have noticed that many software options feature a split view for editing code and previewing changes, such as Dreamweaver. I am on the lookout for a live edito ...

Generating a dataframe with cells that have a combination of regular and italicized text using the sjPlot package functions

I've been trying to set up a basic data table where the genus name in the "Coral_taxon" column is italicized, but the "spp." part following it remains lowercase. I thought of using the expression() function for each row in "Coral_taxon," but so far, I ...

Tips on how to align several divs within another div

I've been attempting to center multiple div blocks within another div or HTML document, but I haven't had any success with the methods I've found on StOv. Here's an image of what I'm aiming for: https://i.stack.imgur.com/DB7uQ.jp ...

Arranging Divs Inside a Container Div - Dealing with Overflow

I am in the process of developing a website that includes a unique structure that I have not encountered before. This layout involves joining multiple sections within a wrapper. As this is my first time attempting such a layout, I am encountering some chal ...

swap between style sheets glitching

My website features two stylesheets, one for day mode and one for night mode. There is an image on the site that triggers a function with an onclick event to switch between the two stylesheets. However, when new visitors click the button for the first ti ...