I'm having trouble getting my <aside> HTML tag to align properly within my grid section

I'm struggling with setting up grids. I have defined the boundaries and everything seems to fall into place within the grid, except for my aside element that I want to appear on the right side of the screen. Interestingly, this issue arises when using SASS. Upon inspecting the grid area using the browser's inspector tool, it does recognize the grid area for my aside.

Despite wanting the aside element to be positioned to the side of the screen, it keeps getting pushed below the "main" part of the grid. HTML:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="css/style.css" type="text/css" rel="stylesheet"/>
<title>MR Blog</title>
</head>

<body>
    <section id="layout">
    <section id="main-nav">
        <nav>
        <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">Contact</a></li>
        <li><a href="#">About</a></li>
        
        </ul>
        </nav>
        </section>
    
    <main>
        <section id="blog">
        <h1>Max's Blog</h1>
    
        
        <h2>Lorem Ipsum</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Magna etiam tempor orci eu lobortis. In hac habitasse platea dictumst quisque sagittis purus sit. Viverra vitae congue eu consequat ac. Nec ultrices dui sapien eget. Tortor at auctor urna nunc id cursus metus aliquam eleifend. A iaculis at erat pellentesque adipiscing commodo elit at imperdiet. Integer malesuada nunc vel risus. Dolor magna eget est lorem. At quis risus sed vulputate. Aenean vel elit scelerisque mauris pellentesque pulvinar pellentesque habitant. Odio pellentesque diam volutpat commodo sed egestas. Enim diam vulputate...

<p>Viverra tellus in hac habitasse platea. Pharetra vel turpis nunc eget lorem dolor. Nulla facilisi etiam dignissim diam quis enim. Turpis in eu mi bibendum neque egestas congue. Urna porttitor rhoncus dolor purus non enim praesent elementum. Dolor purus non enim praesent. A lacus vestibulum sed arcu. Viverra maecenas accumsan lacus vel. Ipsum a arcu cursus vitae congue mauris rhoncus aenean. Blandit turpis cursus in hac habitasse platea dictumst quisque. Tempus urna et pharetra pharetra massa massa ultricies mi quis. Quis blandit turpis cursus in hac habitasse platea dictumst. Id diam maecenas ultricies mi eget mauris pharetra et. Sit amet consectetur adipiscing elit ut. Dignissim convallis aenean et tortor at risus viverra adipiscing at.</p>
        
        
        
        
        </section>
    <section class="social">
    <aside>
        <h3>Find Me Here!</h3>
        
        <p><a href="#">Twitter</a></p>
        <p><a href="#">Facebook</a></p>
        <p><a href="#">Instagram</a></p>
        
        
        </aside>
        </section>
    
    
    
    
    
    
    
    
    </main>
    <footer><p>&copy; Max Reitmayer 2023</p></footer>
    </section>
</body>
</html>

CSS:

#layout {
  display: -ms-grid;
  display: grid;
  -ms-grid-rows: 5em 1fr auto;
  grid-template-rows: 5em 1fr auto;
  -ms-grid-columns: minmax(25em, 1fr) 16em;
  grid-template-columns: minmax(25em, 1fr) 16em;
      grid-template-areas: " nav nav" " main aside" " footer footer";
}

#main-nav {
  -ms-grid-row: 1;
  -ms-grid-column: 1;
  -ms-grid-column-span: 2;
  grid-area: nav;
  background-color: green;
}

#blog {
  -ms-grid-row: 2;
  -ms-grid-column: 1;
  grid-area: main;
  background-color: purple;
}

footer {
  -ms-grid-row: 3;
  -ms-grid-column: 1;
  -ms-grid-column-span: 2;
  grid-area: footer;
  background-color: red;
}

#social {
  -ms-grid-row: 2;
  -ms-grid-column: 2;
  grid-area: aside;
  background-color: orange;
  padding: 1em;
  padding-left: 45px;
}

#mav-nav {
  background: #242469;
  font-color: #D1B53B;
}

html {
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
}

* {
  -webkit-box-sizing: inherit;
          box-sizing: inherit;
}

SCSS of my layout:

#layout {
    display: grid;
 grid-template-rows:5em 1fr auto;
    grid-template-columns: minmax(25em, 1fr) 16em;
grid-template-areas:
" nav nav"
 " main aside"
 " footer footer";
    
}
#main-nav {
    grid-area: nav;
    background-color: green;
    }

 #blog {
    grid-area: main;
    background-color: purple;
    } 


footer {
    grid-area: footer;
    background-color: red;
    }
 #social {
    grid-area: aside;
    background-color: orange;
     padding: 1em;
  padding-left: 45px;
    } 

Answer №1

Your 'aside' component appears below because it is nested within your <main><main/> tag. To fix this, adjust your HTML to allow the aside component to take up its designated grid area:

<html>
<head>
<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="css/style.css" type="text/css" rel="stylesheet"/>
<title>MR Blog</title>
</head>

<body>
    <section id="layout">
    <section id="main-nav">
        <nav>
        <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">Contact</a></li>
        <li><a href="#">About</a></li>
        
        </ul>
        </nav>
        </section>
    
    <main>
        <section id="blog">
        <h1>Max's Blog</h1>
    
        
        <h2>Lorem Ipsum</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Magna etiam tempor orci eu lobortis. In hac habitasse platea dictumst quisque sagittis purus sit. Viverra vitae congue eu consequat ac. Nec ultrices dui sapien eget. Tortor at auctor urna nunc id cursus metus aliquam eleifend. A iaculis at erat pellentesque adipiscing commodo elit at imperdiet. Integer malesuada nunc vel risus. Dolor magna eget est lorem. At quis risus sed vulputate. Aenean vel elit scelerisque mauris pellentesque pulvinar pellentesque habitant. Odio pellentesque diam volutpat commodo sed egestas. Enim diam vulputate ut pharetra sit amet. Morbi tincidunt ornare massa eget egestas purus viverra accumsan. Ut ornare lectus sit amet. Velit egestas dui id ornare arcu odio ut. Viverra vitae congue eu consequat ac felis donec et. Ut tristique et egestas quis. Egestas integer eget aliquet nibh praesent.</p>

<p>Viverra tellus in hac habitasse platea. Pharetra vel turpis nunc eget lorem dolor. Nulla facilisi etiam dignissim diam quis enim. Turpis in eu mi bibendum neque egestas congue. Urna porttitor rhoncus dolor purus non enim praesent elementum. Dolor purus non enim praesent. A lacus vestibulum sed arcu. Viverra maecenas accumsan lacus vel. Ipsum a arcu cursus vitae congue mauris rhoncus aenean. Blandit turpis cursus in hac habitasse platea dictumst quisque. Tempus urna et pharetra pharetra massa massa ultricies mi quis. Quis blandit turpis cursus in hac habitasse platea dictumst. Id diam maecenas ultricies mi eget mauris pharetra et. Sit amet consectetur adipiscing elit ut. Dignissim convallis aenean et tortor at risus viverra adipiscing at.</p> 
        
        </section>
    
    </main>
     <section class="social">
    <aside>
        <h3>Find Me Here!</h3>
        
        <p><a href="#">Twitter</a></p>
        <p><a href="#">Facebook</a></p>
        <p><a href="#">Instagram</a></p>
        
        
        </aside>
        </section>
    <footer><p>&copy; Max Reitmayer 2023</p></footer>
    </section>
</body>
</html>

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

Using jQuery to clear a textarea when a select input is changed

Currently, I am in the process of developing a small text editor that enables users to edit files and create new ones. Here is how I have set up my select menu. <select name="reportname" id="reportname" class="form-control"> <option value="zr ...

Use 'data-toggle='button'' in Angular component only once the condition is validated

Looking to verify a certain condition upon clicking, and if it evaluates to true, toggle the element that was clicked <div class="btn-group btn-group-toggle" data-toggle="buttons"> <label class="btn btn-secondary active" (click)='example ...

Populate the browser screen with a series of unpredictable numbers

I'm looking to fully populate the visible window of a webpage with random numbers. My current approach involves generating a long string of random digits first, and then applying the following properties to a div: #mydiv{ font-family: "Inconso ...

Generate a link to download a music or video file

I have an HTML file containing both video and audio files. I want to link these files, such as MP3 or MP4, using the <a href> tag to allow users to download them. The video and audio files are stored in the same folder as my HTML file. I have attemp ...

An issue has occurred in NextJS - the HookWebpackError is indicating that a pseudo-class or pseudo-element was

When I run next build, I encounter the following error: HookWebpackError: Expected a pseudo-class or pseudo-element. at makeWebpackError (/Users/eliot/Developer/eliothertenstein.com/node_modules/next/dist/compiled/webpack/bundle5.js:28:308185) at / ...

Determine whether a div contains any child elements

I am working on a piece of code that checks for the presence of the class "wrong" in any of my divs, and if found, displays a jQuery UI dialog box. My goal now is to enhance this code by adding a condition where it also checks for empty divs before showing ...

Modify the default navbar from Bootstrap to display as a fixed navbar

Is there a way to change my default navbar into a fixed navbar when I scroll? I have tried adding data-spy="affix" data-offset-top="200", which works but doesn't look quite right. Should I create a new CSS class or is there an easier solution availab ...

Locate numbers 2, 3, 6, 7, and 10, and continue in numerical order, within the

Having trouble with this one. Does anyone know how to display the items like this: 2, 3, 6, 7, 10 and so on... Is there a jQuery or CSS hack that can achieve this? I'm stuck trying to figure it out .container { display: flex; flex-flow: row wra ...

Customizing the background color in TurnJSIncorporating

Recently, I encountered a problem that has left me puzzled. Despite searching online for help, I have not been able to find a solution. The issue lies with the basic code provided on the official page of the TurnJS script. <div id="flipbook"> <di ...

What is the best way to conceal text while retaining icons on a compact screen?

How can I hide the text links for Home, Reservations, My Reservations, About, and Settings on smaller screens while still keeping the icons visible? Currently, I am using the following resources: http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.1 ...

Changes influencing independent div elements

My goal is to design a front-end screen with images labeled steps 1-4 lined up next to each other. The concept is that when the user hovers over one of these steps, the corresponding image should fade in below them in a separate div. Upon removing the curs ...

struggling to insert submit button within input field in bootstrap 4.3.1

Currently, I am working with Bootstrap 4.3.1 and I have been attempting to place a submit button inside an input field. I have tried various methods from StackOverflow but haven't found a solution yet. Since my input has the class rounded-pill, it is ...

Struggling to set the background color for a div element

I am dealing with the following HTML and CSS: <div id="com_loaded"> <div id="com_loaded_userpic"><a href="#" class="tooltip"><img src="pic.jpg" class="img_poster" /><span>Username</span></ ...

The Bootstrap 4 dropdown seems to have a one-time use limit

I'm currently working on a dropdown menu using Bootstrap 4. The dropdown menu is functional, but I'm facing an issue where it only toggles once. I have tried various solutions recommended on different websites, but none of them seem to work. Belo ...

Implementing onMouseEnter and onMouseLeave functionalities for music player

Currently facing a challenge while developing a music player app. I am trying to implement a feature where: Upon hovering over a song, a "play" button should appear in place of the song number. The currently playing song should display a "pause" ...

Error message: Unable to access the state property of an undefined object

I've been attempting to integrate a react sticky header into my stepper component. However, I've encountered an issue where it doesn't render when added inside my App.js file. As a result, I've started debugging the code within App.js ...

Combining various types of media stylesheets with a print stylesheet

I'm struggling with a school assignment that is asking me to compare two different ways of linking a print stylesheet with another stylesheet in HTML. The assignment requires me to explain when each technique would be appropriate: <link rel="style ...

Sliding with jQuery to eliminate a div element

I wanted to dive into jQuery and decided to recreate the slick animation from Jay-Z's new album commercials. In these ads, a bar slides left over his name while simultaneously disappearing. I also wanted to add a flashing effect by fading out, fading ...

Automatically changing the URL of Vue image assets

Is there a way to prevent the URL from changing every time we release in a Vue project when using an image from another project? In my Vue project, I have this code that works fine: <v-img class="header__logo" lazy-src="@/ ...

Conceal the Download Button Effectively

I operate a website for playing audio files and I am looking to prevent users from downloading the sounds using the download button in the HTML audio element. Here is what I came up with: <audio src="sound.mp3" controls controlsList="nodownload">< ...