Allowing the primary content to span the entire width of the mobile screen

I have scoured various forums in search of answers, but unfortunately, I haven't found a solution that fits my specific query. I am looking to ensure that the .main-content (article text and images) occupies the full width of the mobile screen without displaying the .sidebar and .ad sections.

<!DOCTYPE html>
<html lang="en">
    <head>
            <title>Demo</title>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
            <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
            <meta name="HandheldFriendly" content="true">
            <link rel="stylesheet" href="style.css">
            <link rel="stylesheet" href="normalize.css">
    </head> 
    <body>
            <div class="wrapper">   
                <header class="main-head">The Header</header>
                <nav class="main-nav">
                    <ul>
                        <li><a href="index.html">Nav 1</a></li>
                        <li><a href="nav2.html">Nav 2</a></li>
                        <li><a href="nav3.html">Nav 3</a></li>
                    </ul>
                </nav>
                <article class="content">
                            <h1 class="h1">Main article area</h1>
                            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In rhoncus neque mi, suscipit molestie tellus sollicitudin eu. Praesent bibendum lorem at lacus luctus dignissim. Phasellus non volutpat est. Duis sed venenatis arcu, sed accumsan elit. Morbi luctus odio in pellentesque rutrum. Nunc suscipit enim tortor, vel mattis ligula semper a. Mauris at lacinia leo. Aenean luctus elit eget dolor dignissim cursus. Aliquam vulputate ut tellus sed volutpat.
                            Nam consequat arcu id nunc gravida dictum. Mauris mattis vitae metus nec commodo. Vestibulum malesuada mattis ex, sit amet aliquam augue placerat eget. Fusce finibus ullamcorper tortor, vel tempus diam cursus et. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam sit amet turpis diam. In semper lacinia nunc. Fusce risus sapien, sodales vitae pellentesque in, luctus id libero. Nunc ante velit, volutpat vitae dignissim vel, maximus eu lorem. Donec non fermentum nisl. Praesent vitae accumsan nisi, eu porta diam.</p>
                            <br>
                            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In rhoncus neque mi, suscipit molestie tellus sollicitudin eu. Praesent bibendum lorem at lacus luctus dignissim. Phasellus non volutpat est. Duis sed venenatis arcu, sed accumsan elit. Morbi luctus odio in pellentesque rutrum. Nunc suscipit enim tortor, vel mattis ligula semper a. Mauris at lacinia leo. Aenean luctus elit eget dolor dignissim cursus. Aliquam vulputate ut tellus sed volutpat.
                            Nam consequat arcu id nunc gravida dictum. Mauris mattis vitae metus nec commodo. Vestibulum malesuada mattis ex, sit amet aliquam augue placerat eget. Fusce finibus ullamcorper tortor, vel tempus diam cursus et. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam sit amet turpis diam. In semper lacinia nunc. Fusce risus sapien, sodales vitae pellentesque in, luctus id libero. Nunc ante velit, volutpat vitae dignissim vel, maximus eu lorem. Donec non fermentum nisl. Praesent vitae accumsan nisi, eu porta diam.</p...
                            <img src="image.webp" alt="Dummy" class="responsive">
                </article>
                <aside class="side">Sidebar</aside>
                <div class="ad">Advertising</div>
                <footer class="main-footer">The footer</footer>
            </div>       
    </body>
</html>

.wrapper {
    display: grid;
    grid-gap: 0;
    grid-template-columns: 1fr 4fr 1fr;
    grid-template-rows: auto auto 1fr auto;
    height: 100vh;
    grid-template-areas: 
      "header  header    header"
      "nav     nav       nav"
      "sidebar article   ad"
      "footer  footer    footer";
}
body, html {
    height: 100%;
    width: 100%;
    padding: 0;
    margin: 0;
    font-family: 'Times New Roman', Times, serif;
    font-size: 100%;
}
.main-head {
    grid-area: header;
    background-color: teal;
    background-color: red !important;
}
.content {
    grid-area: article;
    width: 100%;
    background-color: orange;
    background-color: white !important;
}
.main-nav {
    grid-area: nav;
    background-color: lightblue;
    background-color: red !important;
    top: 0;
    width: 100%;
    position: sticky;
    z-index: 9999; 
}
.side {
    grid-area: sidebar;
    background-color: tomato;
    background-color: white !important;
}
.ad {
    grid-area: ad;
    background-color: lightgreen;
    background-color: white !important;
}
.main-footer {
    grid-area: footer;
    background-color: ghostwhite;
}
li {
    list-style-type: none;
    margin: 0;
    padding: 1rem;
}
a {
    text-decoration: none;
    color: black;
}
ul { 
    display: flex;
    padding: 0;
    margin: 0;
    }
.main-head, .content, .side, .ad, .main-footer {
    padding: 1rem;
}
.responsive {
    max-width: 100%;
    height: auto;
}
.h1 {
    font-size: 48px;
}
a:hover {
    color: white;
}
/* Media Queries: Tablet Landscape */
@media screen and (max-width: 1060px) {
    #primary { width:67%; }
    #secondary { width:30%; margin-left:3%;}  
}
/* Media Queries: Tabled Portrait */
@media screen and (max-width: 768px) {
    #primary { width:100%; }
    #secondary { width:100%; margin:0; border:none; }
}

I appreciate any assistance and feedback on potential improvements or corrections needed in my code. Thank you!

Answer №1

It seems like the article is not extending to full width because the display property in the .wrapper class is set to grid. The CSS Grid Layout Module provides a structured layout system with rows and columns. To ensure your article spans the entire width, change .wrapper{display: block} for responsiveness. I hope this solution works for you!

@media screen and (max-width: 767px){
   .wrapper{display: block;}
}

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

What is the best way to align a modal with a layout when it appears far down the components hierarchy?

Struggling with creating a React modal and facing some issues. Let's consider the structure below: React structure <ComponentUsingModal> <Left> <ButtonToActivateModal> ... </ButtonToActivateModa ...

What is the best way to include a new property to an existing interface and then export the updated interface in Typescript?

Can you provide guidance on creating a new interface - UIInterface that combines SummaryInterface with additional properties? For example: import { SummaryInterface } from 'x-api'; // summaryInterface includes 20+ predefined properties generated ...

Python regular expression problem with matching regex

Hey there, I'm diving into my first question on stackoverflow and I've been struggling with it for hours. I'm sure the solution is right in front of me, but I just can't seem to find it. My goal is to extract information from a webpage ...

When an AJAX call is made during a PHP session that has timed out

I am working on an AJAX form that handles data authentication. In the event of a session timeout, I need to implement a redirect to the login page. How can I go about achieving this? Here is an excerpt from my simplified server-side code: function doExecu ...

What could be causing the issue of my navbar text not changing color using CSS?

Despite several attempts, I am unable to change the color of the hyperlinks in blue or purple using the HTML and CSS below. Can anyone point out what I might be missing? nav ul { /* Navbar unordered */ list-style: none; text-align: center; backgr ...

Utilizing the Fetch API to retrieve a Flickr feed in JSON structure

When interacting with the flicker feed API, I have successfully received a JSON response using $.getJSON. However, when attempting to use Fetch instead, only an XML response seems to be retrieved. Example of working with $.getJSON: var flickerAPI = "http ...

Baffling Visibility Issue: iframe's Transparency Lost in Chrome and IE, Only Visible in Firefox

I have encountered a puzzling issue: http://jsfiddle.net/akosk/t2KvE/8/ HTML <div id='base'> <iframe id="myFrame" src="about:blank" frameborder="0" allowTransparency="true"></iframe> </div> <script id="conte ...

Removing Multiple Object Properties in React: A Step-by-Step Guide

Is there a way in React to remove multiple object properties with just one line of code? I am familiar with the delete command: delete obj.property, but I have multiple object properties that need to be deleted and it would be more convenient to do this i ...

Leverage express for proxying websocket connections

Currently, I am facing a situation where my data provider gives me stock prices through a TCP connection but only allows a static IP to access their service. Since I need to format the data before sending it to my front-end, I plan to utilize my express ba ...

I can't see the presence of spin.js on my website

I am completely new to Javascript and I'm trying to implement a loading spinner on my website. Whenever users tap the screen, it takes some time to navigate to the desired URL, so we need a spinner to prevent them from tapping repeatedly. I decided t ...

Transferring an object from the factory to the controller

I'm currently working on setting up a factory that sends an ajax request to an API and then returns a data object. Here is the code snippet I have written: app.factory('Test', function($http, $q) { var data = {response:{}}; var getM ...

How to Get into a Nested Class in JavaScript

I'm struggling to articulate my question, but I know there's a solution out there. I have profile cards in HTML, each with the class "card" containing two numbers. My goal is to display a progress bar specific to the % relationship of these numbe ...

Differences in characteristics of Javascript and Python

As I tackle an exam question involving the calculation of delta for put and call options using the Black and Scholes formula, I stumbled upon a helpful website . Upon inspecting their code, I discovered this specific function: getDelta: function(spot, str ...

The page only appears properly after clearing the cache

My floating list menu is behaving oddly in Firefox. It only displays correctly after clearing the cache, but as soon as I refresh the page, the menu breaks again. The links inside the list elements appear wider than the text, even though I haven't se ...

Guide to implementing CSS3 transitions with prefixes using JavaScript

Is there a way to apply CSS styles using JavaScript when I don't have access to the CSS file? #fade div { -webkit-transition: opacity 1s; -moz-transition: opacity 1s; -o-transition: opacity 1s; -ms-transition: opacity 1s; transition: ...

Using iScroll without animation by using scrolltoelement on an iPhone PhoneGap application

I've been working on an iOS PhoneGap app that uses Backbone and some other libraries. To handle scrolling, I implemented iScroll which has been functioning properly. However, I encountered a problem with the following code snippet: events: { &apo ...

What was the reason for Vue's decision to deprecate the ""is" attribute for HTML elements?

Vue's eslint rules mention that the is attribute on HTML elements is deprecated (since 3), and should be used on components instead: <template> <!-- ✓ GOOD --> <div /> <component is="foo"> <!-- ✗ BAD --&g ...

Error: Type Error when using custom App and getInitialProps in Next.js

I have a simple app built using the Next JS starter kit, and I am attempting to integrate custom functionality as outlined in the documentation: class MyApp extends App { static async getInitialProps({ Component, router, ctx }) { let pageProps = {}; ...

To redirect to a webpage in PHP, incorporate nested if statements and override the meta HTML

I am looking for a way to automatically redirect to another webpage when a certain condition is met. Currently, I have set up a meta redirect in case the condition is not satisfied. <meta http-equiv="refresh" content="4; url=form3.html" /> <?ph ...

Unable to use jQuery to delete class from an element

Here is the markup I am working with: <div class="row"> <img src="image.png" class="download-image regular-image" /> <div class="options"> <p>download</p> </div> <img src="image.png" class="download-image r ...