The media query paragraph is not displaying across the full width of the mobile screen

Issue: I am looking to make my paragraph span the entire width of a mobile screen. How can I achieve this? Here is an image depicting the problem I am facing https://ibb.co/VvtRx1H. I specifically want the paragraph enclosed in a red border to be displayed across the entire mobile screen.

CSS code snippet:

   *{
    margin:0; padding:0; box-sizing: border-box;
   
}

h1{
    text-transform: uppercase;
    margin:50px 0;
    text-align: center;
}
.parent{
    width:100%;
    height:50vh;
    display: flex;
    justify-content: space-around;
    align-self: center;
}
.daughter{
    width:50%;
    text-align: center;
    padding:0;
}
.daughter img{
    width:450px;
}
.son{
    width:50%;
    padding:0 5%;
    box-sizing: border-box;
    line-height: 1.7;
    text-align: justify;
}

@media (max-width:768px){
    h1{
        color:red;
    }
    .parent{
        display: block;
    }
    .daughter{
        width:100%;
    }
    .son{
        width:100%;
    }
}
@media (max-width:468px){
    .daughter img{
        padding:10%;
        box-sizing: border-box;
    }
    
}
@media (max-width:410px){
    .daughter img{
        padding:10%;
        box-sizing: border-box;
    }
    .son{
        border:1px solid red;
    }
    
}

Sample HTML markup:

<body>
<h1>My WEBSITE</h1>
<br>
<div class="parent">
    <br>
    <div class="son">
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore minima doloremque aliquid ad voluptates iste dicta officiis repellat nesciunt a.</p>
        <br>

    </div>
    <div class="daughter">
        <img src="images/11.jpg" alt="image">

    </div>

</div>

Answer №1

Adjustments necessary to resolve the issue: Correction required in Line 55 of the CSS code.

@media (max-width:410px){
    .daughter img{
        padding:10%;
        box-sizing: border-box;
    }
    .son{
        border:1px solid red;
        height: 85vh;
        width: 100%;
    }
    .son p{
        height: 95%;
        text-align: center;
    }
}

Answer №2

Include meta tags in the head section of your website

<meta content="width=device-width, initial-scale=1" name="viewport" />

Update Styling

*{
    margin:0; padding:0; box-sizing: border-box;
   
}

h1{
    text-transform: uppercase;
    margin:50px 0;
    text-align: center;
}
.parent{
    width:100%;
    height:50vh;
    display: flex;
    justify-content: space-around;
    align-self: center;
}
.daughter{
    width:50%;
    text-align: center;
    padding:0;
}
.daughter img{
    width:450px;
}
.son{
    width:50%;
    padding:0 5%;
    box-sizing: border-box;
    line-height: 1.7;
    text-align: justify;
}

@media screen and (max-width: 768px) {
    h1{
        color:red;
    }
    .parent{
        display: block;
    }
    .daughter{
        width:100% !important;
    }
    .son{
        width:100%;
    }
    .parent{display: inline;}
}
@media (max-width:468px){
    .daughter img{
        padding:10%;
        box-sizing: border-box;
    }
    
}
@media (max-width:410px){
    .daughter img{
        padding:10%;
        box-sizing: border-box;
    }
    .son{
        border:1px solid red;
    }
    
}

Here is the HTML structure

<h1>Welcome to My Website</h1>
<br>
<div class="parent">
    <br>
    <div class="son">
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore minima doloremque aliquid ad voluptates iste dicta officiis repellat nesciunt a.</p>
        <br>

    </div>
    <div class="daughter">
        <img src="images/11.jpg" alt="image">

    </div>

</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

Adjust the appearance of primeng's PanelMenu component

I've been attempting to customize the appearance of the PanelMenu component So far, I've successfully changed the overall background color. https://i.sstatic.net/MGIia.png My goal is to set the main menu items to white and the submenus to blac ...

What is the best way to delete specific elements or text from a dialog box when it is closed?

I'm facing an issue with removing text in a dialog upon closing it. The page contains multiple dialogs, each with some forms inside. One form is for sending messages to users and the other is for updating user information. After submitting a form, a ...

How to handle unclickable buttons in Selenium testing

from selenium import webdriver from time import sleep from selenium.webdriver.common.by import By chrome_options = webdriver.ChromeOptions() driver = webdriver.Chrome(r'chromedriver.exe', options=chrome_options) url = 'https://rarible.com/c ...

Create a table containing selected lines extracted from a paragraph

To begin with, let's take a look at the FIDDLE. This is a snippet from my current project, where there is an abundance of HTML content. Hence, I will only display the basic structure: <div class="line"> <table> <tbody> ...

I am trying to make my CSS divs remain in the exact same position on the background image, even when the browser is resized both horizontally and vertically. How can I achieve this?

I need the red dot divs to remain fixed on a world map, regardless of browser resize. Not sure if I should be adjusting div properties or background. Here's my CSS code, any feedback is appreciated as I'm new to web design: HTML: <!DOCTYPE ...

Processing of an array received via AJAX and passed to a PHP script, inside a separate function in a different file

I have a JavaScript array that I am sending via AJAX to a PHP file named aux.php. What I want is for this array to be visible and manipulable within a function inside a class in another PHP file called payments.php. I've provided all the code so they ...

Converting HTML to DOC with PHP

Looking for a way to convert an HTML file into a DOC format. Currently using html2pdf for PDF conversion. Does anyone know of a similar library that can convert HTML to DOC? Must be free or open source. (PS must be free/open source) EDIT Received feedb ...

The functionality of jquery.load() seems to be experiencing issues in Internet Explorer when attempting to load an HTML file

Code $('.form').load('http://'+window.location.hostname+':8423/html/form/form_generate.html/?session='+session); In an attempt to load a html file from a different port on the same server. The original server is accessible ...

Easily convert 100% of the height to pixels

Is there a way in HTML to convert a div's height from 100% to pixels without specifying a particular pixel value? ...

Seamless infinite background scrolling on the canvas without any disruptions

In my HTML5/JS project, I have implemented infinite background scrolling using multiple canvases. The challenge I am facing is that while the animation is smooth after rendering, there is a quick hiccup when transitioning to the next frame due to the need ...

Arranging pagination elements for table stacking on smaller screens

Below is a code snippet showcasing the table pagination elements and styles I'm using. The layout looks great on medium and larger screens, but when viewed on smaller screens, the pagination elements wrap to the next line while the counts remain float ...

Issue with AngularJS pagination: unable to detect the current page number

I am currently developing a compact application that showcases a JSON object of "users" in an HTML5 table. The application is built using Bootstrap 3 and AngularJS, and I have the intention to implement pagination for this table. Instead of having an arra ...

Formatting styles for child components' templates using Angular's parent component CSS styling

Is there a way to override CSS of a child component from the parent using ::ng-deep or another method? In my parent component, I have included a child component like this: ....parent.component... <app-likes></app-likes> .....parent.component.. ...

Tips on eliminating expansion upon button click in header within an Angular application

While utilizing Angular Materials, I encountered a challenge with the mat-expansion component. Every time I click on the buttons within the expansion panel, it closes due to the default behavior of mat-panel. Requirement - The panel should remain expanded ...

Update the color scheme of a striped table in Bootstrap 4 beta (currently the latest version)

My table is designed with stripes using the following code: <table class="table-sm table-hover table-striped"> <thead> <tr> <th>#</th> <th>First Name&l ...

Buttons in HTML function properly on desktop but are ineffective on mobile devices

My website is almost complete, but I am facing some challenges with the mobile version. All buttons that use JavaScript are not functioning properly, whereas buttons with simple links work perfectly fine. This issue doesn't occur on Chrome when using ...

Learning to activate music on a webpage using the tab key in HTML

Is there a way to trigger the playback of an mp3 file when the tab key is pressed on a keyboard? I am designing a number system for a restaurant where entering a number and pressing tab will result in a noise being played to bring attention to the numbers ...

Arranging input elements horizontally

this issue is connected to this post: Flex align baseline content to input with label I am grappling with the layout of my components, specifically trying to get all inputs and buttons aligned in a row with labels above the inputs and hints below. The CSS ...

Using Jquery .ajax to Populate Select Dropdown with JSON Data

I have put in a lot of effort but I'm not seeing any results. My JSON data, created with PHP, looks like this (with the header sent before the data): {"users":[ {"id":"3256","name":"Azad Kashmir"}, {"id":"3257","name":"Balochistan"}, {"id":"3258","na ...

Challenges arise with dynamic tables (Foundation 5) within Rails application

I have tables set up in my Rails 4 App with the ZURB Foundation 5 framework. The problem lies with the mobile version of the table. It works fine on browsers and tablets, but on mobile phones, it shows the first column twice before scrolling through the r ...