Embark on the journey of creating a beginner-level page layout using HTML and CSS!

I've been tasked with creating a complete page layout. My goal is to fill all the empty spaces between my layout colors using grid, but I'm facing an issue where I can't fully span the navbar to take up the entire space at the top of the browser. There seems to be some margin that I can't override.

I've attempted to use grid-template-column: 1/5 and other methods, but I'm struggling to figure it out. The code snippets are provided below:

html,
body {
  display: grid;
  grid-col height: 100%;
  width: 100%;
}

.zone {
  padding: 30px 50px;
  margin: 40px 60px;
  cursor: pointer;
  display: inline-block;
  color: #FFF;
  font-size: 2em;
  border-radius: 4px;
  border: 1px solid #bbb;
  transition: all 0.3s linear;
}

.zone:hover {
  -webkit-box-shadow: rgba(0, 0, 0, 0.8) 0px 5px 15px, inset rgba(0, 0, 0, 0.15) 0px -10px 20px;
  -moz-box-shadow: rgba(0, 0, 0, 0.8) 0px 5px 15px, inset rgba(0, 0, 0, 0.15) 0px -10px 20px;

/* Remaining CSS code for different background colors */

<!DOCTYPE html>
<html>

<head>
  <title>Layout Master</title>
  <link rel="stylesheet" type="text/css" href="./style.css">
</head>

<body>
  <div class="zone green">Header</div>
  <div class="zone red">Cover</div>
  <div class="zone blue">Project Grid</div>
  <div class="zone yellow">Footer</div>
</body>

</html>

Answer №1

It seems like there may be some confusion in your question, but I'll do my best to provide some helpful information. If you're experiencing spacing at the top of your page, it's important to reset the browser's default styling. Resetting the body element can help:

body{ 
 display: block;
 margin: 8px;
}

For a full list of CSS default values, you can refer to this link.

You might also consider using a CSS normalization tool like normalize.css.

Additionally, for examples of CSS grid layouts, you can check out grid layouts.

When dealing with height and width in CSS, keep in mind units like vw and vh which are based on the current viewport size. Learn more about viewport units here.

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

Retrieving table information using curl and regular expressions

Here is the code I have developed to extract data from a table on a specific website. However, I am looking to remove any links present in the data and also separate the title and price into an array. <?php $ch = curl_init("http://www.digionline.ir/ ...

Angular allows for the creation of a unique webpage layout featuring 6 divs

I am working on a project where I have an image of a car and I need to overlay 6 divs onto the image which can be selected with a mouse click. When a user clicks on one of the divs, it should change color. I've attempted using z-index, but it doesn&ap ...

Developing a Form Submission Feature Using JQuery Mobile

I'm having trouble submitting a form using JQuery Mobile. Currently, my code looks like this: <form action="#pagetwo" method="post" name="myform"> <input type="text" name="myname"> <input type="submit" value="submit" /> ... and th ...

What is the proper way to reference automatically generated class names within nested style rules when using makeStyles in Material-UI?

When using makeStyles, how can I reference generated classnames when creating nested rules? For instance, if I have a "container" class with nested "item" elements and I want to use the generated "item" class in the style definition. The approach that wor ...

Guide to adding a period symbol using HTML5 speech recognition technology

I have been implementing the HTML5 speech recognition feature on my website with success. Previously, when I would say "full stop," it would display "." as expected. However, over the past four days, it has been transcribing the words "full stop" instead o ...

Delete the browsing cache in Internet Explorer from an external source

Currently, I am working on developing an ASP.NET application using Visual Studio. However, a persistent issue I am facing is that every time I launch the application, Internet Explorer caches certain CSS and JS files. This forces me to manually clear the c ...

Using javascript to locate and substitute a word divided among multiple tags - a step-by-step guide

I need to utilize JavaScript to locate and substitute a word that has been separated into multiple tags. For instance, consider the following HTML code: <html> <body> <div id="page-container"> This is an apple. ...

Is there a way to invoke a client-side function from the server?

Is there a way to display an alert at the top of the browser if the SQL query returns empty results? I tried using the "alert" function, but I'm struggling with customizing its appearance. I have a function in my HTML code that triggers an alert, but ...

Ways to maintain image alignment regardless of the size of the window or device?

Let's set the scene. I'm working with 2 images, a background image for a div and another regular image inside that same div. My question is, how can I ensure that both images are always in the exact position of each other, even when viewed on di ...

In Internet Explorer, the Textarea fails to display new lines

It appears that when text is placed into a textarea, IE ignores \r\n while FF/Chrome/Opera do not. Here's how the rendering differs: Paragraph1 sometext Paragraph2 othertext In IE7/8, however, it renders as: Paragraph1 sometextParagraph2 ...

Attempting to create a multi-page slider using a combination of CSS and JavaScript

Looking for help with creating a slider effect that is triggered when navigating to page 2. Ideally, the div should expand with a width of 200% or similar. Any assistance would be greatly appreciated! http://jsfiddle.net/juxzg6fn/ <html> <head& ...

Tips for Retrieving Html Element Attributes Using AngularJS

Update: Even though the discussion veered off track, the main question still stands - how can I access an attribute of an HTML element within an Angular controller? Check out my attempt on Plnkr: http://plnkr.co/edit/0VMeFAMEnc0XeQWJiLHm?p=preview // ...

What is the best way to fill in the jquery treeselect widget?

I'm struggling with populating the jquery treeselect widget using a json file or any other method. Since I am new to jquery/javascript, I'm sure I must be missing some basics. Although I have obtained the plugin from https://github.com/travist/j ...

What is the best way to access an element's sibling using JQuery within a function?

How can I use JQuery to set an element to match the value of its sibling? In a table with multiple fields, when clicking an Edit button, I want to copy the label value to its adjacent input field: <table style="width:90%"> <tr> <td&g ...

Is JSDOM able to handle media queries?

I understand that JSDOM may not have all the features of a full-fledged browser, but there is mixed information out there about its CSS support. While I've personally seen it parse CSS, responsive styles don't seem to function as expected. Can an ...

Align text in block beneath image on a new row using Bootstrap 4

I have set up a layout that I like, but I am looking to align the text under each image in a block directly below it. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet"/> <div class="co ...

Compact selection box, vast information

My dilemma is having restricted space for a dropdown containing a considerable amount of text. Is it feasible to keep the dropdown width small while expanding the list popup size? Update: My browser of choice is Internet Explorer. ...

Change the global type-selector class dominance

I have a variety of form pages in my application, all with text box elements that share the same global CSS rules like width (150px), font-family, and font-size. To streamline this, I created a global CSS type selector class for most text boxes. However, s ...

upright scrolling mouse slider

In my project, I have implemented a vertical slider with mousewheel control using SwiperJS from https://swiperjs.com/. Although the slider is working perfectly fine, I am looking to fix the positions while scrolling on the page similar to the example pro ...

Is there a way to remove any excess white space towards the top?

Hello once again, I've reached a frustrating point in my learning journey. There seems to be extra space at the top with every browser see image here. I tried using body {overflow:auto;} in the CSS but it only worked up to a certain extent, getting ri ...