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

Utilize jQuery to hide and then show elements based on text input

Recently, I came across a useful jQuery filter example that sparked my interest. To test it out, I created my live example and shared the code on CodePen (or you can check out the Fiddle if you prefer). One issue I encountered was that after entering text ...

What is the best way to retrieve user groups in Django?

My goal is to investigate the user groups associated with a user in Django. However, when I check the console, I encounter the message: Uncaught ReferenceError: user is not defined at 6/:643:33 The purpose of the function is to redirect the user based ...

React - method for transmitting dynamically generated styles to a div element

As a newcomer to the world of React, I keep encountering an unexpected token error related to the ":". Can someone please assist me with understanding the correct syntax for including multiple styles within the Box component provided below? Additionally, h ...

Floating Div Elements

Trying to solve this seemingly simple problem has been quite the challenge for me. I have a container with multiple divs added to it, and I want these divs to position themselves freely within any available white space. However, they must follow a pattern ...

The vertical-align property in CSS fails to function properly when applied to specific rows or columns within the

Hello, I have been experimenting with table attributes and came across the valign attribute. However, I encountered some cells that were not affected by it. So, I decided to try CSS vertical-align instead. To my surprise, some cells were affected while oth ...

Filling HTML5 Datepicker Using Information from a Model

Currently, I am in the process of developing a basic scheduling application for a project. To simplify the task of selecting start and end times/dates for our events, we have included a simple DateTime picker in the source code: <input type="datetime-l ...

Is it possible to change the background color of the scrolling page?

Let's say I have 10 different sections, each with a unique background color assigned to them. As the user scrolls down from section 1 through 10, my goal is to dynamically change the body tag's background color based on which section is currentl ...

Dropdown selection returning the text value instead of the designated value

Is it possible to retrieve the text "Region 1" instead of just the value '1' from a dropdown menu in PHP? <select name = 'region' id = 'region'> <option value = '1'>Region 1</option> <select&g ...

Discover the complete compilation of CSS class regulations (derived from various stylesheets) along with their currently active properties for the chosen element

Is there a way to retrieve all the matched CSS Selectors for a selected element and access the properties of each active class applied to that element? I have researched methods like using getMatchedCSSRules and checking out However, I am hesitant to use ...

CSS: A guide to creating layouts

I wrote this code snippet to display a table: <div class="topologyBalloon" id="bl_c2f03b99-6d62-43c4-9a35-4b4cbf22a7db"> <a href="#close" class="closeTopologyBalloon">×</a> <div class="contentBody"> <table class="deta ...

How can JavaScript pass a variable through the URL?

I am attempting to pass a variable through the URL: http://localhost/new_wiki/test.php?id=http://example.com In my code, I have var first = getUrlVars()["id"];. This line is supposed to pass the value but it doesn't seem to be working. Can someone pl ...

Unlocking the Possibilities of scroll-snap-type

My goal is to effectively utilize the scroll-snap-type property I'm struggling to understand why this code functions as intended html, body { scroll-snap-type: y mandatory; } .child { scroll-snap-align: start none; border: 3px dashed blac ...

Exploring the differences between the meta viewport and font size

My website includes the following code in the section: <meta name="viewport" content="width=990"/> This setting helps to display my webpage well on mobile devices, as using width=device-width causes issues with elements that have 100% width. Howeve ...

Custom view with spannable text functionality

Can a custom view be included in a spannable text? I've noticed various types of spannable objects in the android.text.style package, but I'm curious if it's possible to insert a custom view. Something like spanable.setSpan(CustomView, .. ...

Tips for including a wildcard in a MySQL query while using the '=' operator

I am working with pre parameters that determine the input for my query. For one scenario, I need to search for all UUIDs, while in another situation, I only want to look for specific UUID numbers. Instead of splitting this into two separate calls as shown ...

In Javascript, when trying to call Firebase database child(), it may sometimes result in the return value being "

Here is the current setup: Firebase Database: setores: { -KkBgUmX6BEeVyrudlfK: { id: '-KkBgUmX6BEeVyrudlfK', nome: 'test' } -KkDYxfwka8YM6uFOWpH: { id: '-KkDYxfwka8YM6uFOWpH', nome ...

The outcome of the Python web crawling did not meet our expectations

After using Selenium to scrape web data, I encountered an issue where it only displayed 96 out of 346 products instead of the expected 346. Does anyone have suggestions on how to fix this problem? The crawling code is placed right after the loop for clicki ...

Avoid displaying the homepage link in the menu on Grav

I'm working on my very first Grav website. Currently, I am in the process of creating a navigation menu and would like it to display links to all visible pages except for the homepage. The issue I'm facing is that the homepage appears as the fir ...

Unlocking the full width potential of your HTML page in the browser

Currently, I am utilizing Twitter Bootstrap 3.3.5 within my Grails application. However, an issue has arisen where my GSP view is not displaying in full screen. Is there a way to achieve full screen display without disrupting the responsive features of B ...

Tips for changing the background color of a dropdown menu when hovering in Zurb Foundation 5

Is there a way to customize the background color when hovering over <a href="#">Find Me</a>? I want the background color to change while hovering, similar to how it appears in the image before hovering. And this is how it looks after hovering: ...