Stylish Card Design

Below is the CSS code:

*{margin:0;

  padding:0;

  box-sizing:border-box;

}



img{

  display:block;

  max-width:100%;

  height:auto;

}



html{

  scroll-behavior:smooth;

}







body{

  min-height:100vh;

  font-family:fantasy;

  font-size:1.125rem;

  display:flex;

  flex-direction:column;

  background-color:#BF4F51;

  background-image:linear-gradient(315deg, #BF4F51 0%, #00C6A7 74%);}



header,footer{

  background-color:#333;

  color:#fff;

  padding:1rem;

  position:sticky;

  text-align:center;



}

header{

  top:0;

  font-size:3rem;

}



footer{

  bottom:0;

  font-size:1.5rem;

}



nav{

  background-color:papayawhip;

  padding:1rem;

  display:flex;

  justify-content:space-evenly;

  text-align:center;

  font-size:1.5rem;

  margin-bottom:1rem;

  margin-top:1rem;

}



nav a,

nav a:visited{

  color:black;

  text-decoration:none;

}



nav a:hover, nav a:focus{

  color:brown;

}





main{

  flex-grow:1;

  display:flex;

  flex-direction:column;

  gap:2rem;

  padding:0.5rem;

  justify-content:center;

  align-items:center;

  

}



.card{

  scroll-margin-top:8rem;

  width:min(100%, 400px);

  background-color:beige;

  border:2px solid black;

  border-radius:20px;

  padding:3rem;

  display:flex;

  flex-direction:column;

  text-align:center;

  

}



.card img{

  border:2px solid black;

  border-radius:1000px;

}



.card figcaption{

  margin:1rem;

  font-weight:bolder;



<html>



<head>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width">

  <title>Laylatul Qadr</title>

  <link href="style.css" rel="stylesheet">

</head>



<body>

  <header>

    <h1>Laylatul Qadr</h1>

  </header>

  <nav>

      <a href="#Qirat">Qirat</a>

      <a href="#Qiyam">Qiyam</a>

      <a href="#Siyam">Siyam</a>

  </nav>

  <main>

    <article id="Qirat" class="card">

      <figure>

        <img src="feea4181f154cb619ce78d6f10b310f0.jpg" height="1308" width="736" alt="Qirat">

        <figcaption>Qirat</figcaption>

        <p><q>Reflect on the ayahs.</q></p>

      </figure>

    </article>

    

    



    <article id="Qiyam" class="card">

      <figure>

        <img src="1c6c718d1b3a84f33af850da377ed593.jpg" height="853" width="640" alt="Qiyam">

        <figcaption>Qiyam</figcaption>

        <p><q>Engage more in Qiyam Al layl.</q></p>

      </figure>

    </article>

    <article id="Siyam" class="card">>
  
      <figure>
  
        <img src="eb538cd47834af92764559818a1434cc.jpg" height="989" width="736" alt="Siyam">
  
        <figcaption>Siyam</figcaption>
  
        <p><q>Fast with the intention of your sins being forgiven.</q></p>
  
      </figure>
  
    </article>
  
  </main>
  
  <footer>
  
    <p>Make The Most Out Of This Last 10 days!</p>
  
  </footer>
  
</body>
  
  
  
</html>

The issue here is that the header, nav, and footer elements' background colors are not covering the full width of the page when viewed in mobile view on Chrome. It only covers half of the screen. Here are the screenshots to illustrate the difference: Mobile View

This shows how it looks without desktop view.

And this is how it appears with desktop view: Desktop View

I am currently learning CSS and I am struggling to understand what went wrong. I attempted to use media queries but that did not resolve the issue. Can someone please guide me on what needs fixing here?

Answer №1

I've updated your header, footer, and nav elements with a width of 100% and made some property adjustments.

The best approach is to utilize media queries to apply different styles based on screen size.

Hopefully, this information proves helpful!

*{margin:0;

  padding:0;

  box-sizing:border-box;

}



img{

  display:block;

  max-width:100%;

  height:auto;

}


body{

  min-height:100vh;

  font-family:fantasy;

  font-size:1.125rem;

  display:flex;

  flex-direction:column;

  background-color:#BF4F51;

  background-image:linear-gradient(315deg, #BF4F51 0%, #00C6A7 74%);}



header,footer{

  background-color:#333;

  color:#fff;

  padding:1rem;

  text-align:center;

width: 100%; /* full width */


}


nav{

  background-color:papayawhip;

  padding:1rem;

  display:flex;

  justify-content:space-evenly;

  text-align:center;

  font-size:1.5rem;

width: 100%; /* full width */

}



nav a,

nav a:visited{

  color:black;

  text-decoration:none;

}



nav a:hover, nav a:focus{

  color:brown;

}





main{

  flex-grow:1;

  display:flex;

  flex-direction:column;

  gap:2rem;

  padding:0.5rem;

  justify-content:center;

  align-items:center;

  

}



.card{

  scroll-margin-top:8rem;

  width:min(100%, 400px);

  background-color:beige;

  border:2px solid black;

  border-radius:20px;

  padding:3rem;

  text-align:center;

  

}



.card img{

  border:2px solid black;

  border-radius:1000px;

}



.card figcaption{

  margin:1rem;

  font-weight:bolder;
<html>



<head>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width">

  <title>Laylatul Qadr</title>

  <link href="style.css" rel="stylesheet">

</head>



<body>

  <header>

    <h1>Laylatul Qadr</h1>

  </header>

  <nav>

      <a href="#Qirat">Qirat</a>

      <a href="#Qiyam">Qiyam</a>

      <a href="#Siyam">Siyam</a>

  </nav>

  <main>

    <article id="Qirat" class="card">

      <figure>

        <img src="feea4181f154cb619ce78d6f10b310f0.jpg" height="1308" width="736" alt="Qirat">

        <figcaption>Qirat</figcaption>

        <p><q>Reflect on the ayahs.</q></p>

      </figure>

    </article>

    

    



    <article id="Qiyam" class="card">

      <figure>

        <img src="1c6c718d1b3a84f33af850da377ed593.jpg" height="853" width="640" alt="Qiyam">

        <figcaption>Qiyam</figcaption>

        <p><q>Engage more in Qiyam Al layl.</q></p>

      </figure>

    </article>

    <article id="Siyam" class="card">

      <figure>

        <img src="eb538cd47834af92764559818a1434cc.jpg" height="989" width="736" alt="Siyam">

        <figcaption>Siyam</figcaption>

        <p><q>Fast with the intention of your sins being forgiven.</q></p>

      </figure>

    </article>

  </main>

  <footer>

    <p>Make The Most Out Of This Last 10 days!</p>

  </footer>

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

Unable to Send Messages through HTML Email Form

I have recently obtained a Bootstrap website template and I am facing an issue with the functionality of the form that is supposed to send messages to my email. Despite filling in all the required fields, the message confirms submission but no actual email ...

Is there a way to customize my visual studio code to automatically insert an indented space between curly brackets in CSS when I press enter?

Whenever I try to open curly brackets in CSS and press enter, it simply moves to the next line without adding an indentation as shown below: body { } Despite going through the settings and experimenting with different options, I haven't been able to ...

The CSS file is not appearing, causing the styling not to be applied

I've included the following line in my html file: <link rel="stylesheet" href="css/styles.css"> Despite having the css file linked, the styling is not visible on the page. The HTML remains plain. The structure of my files is as follows: file ...

Tips for entering text into the redactor editor with selenium IDE

The redactor editor's HTML structure is as follows: <div class="redactor_text redactor_optional redactor_editor" contenteditable="true" dir="ltr" style="height: 373px;"> <p>dummy text​</p> //This is where the text inputted into ...

Diverse positioning across various browsers

I have a navigation menu with alternating divs - one containing a menu link and the other a 'menu separator' div with a 2px wide 'separator bar' image. The width of the separator divs is set to 24px to create proper separations. For so ...

What is the best way to eliminate quotation marks surrounding a boolean value within a JSON string?

The current string is: String example = {"test":"true"} However, I would like it to be in this format: example = {"test":true} Is there a way to convert the initial string to match the desired format? ...

What could be causing my jQuery to malfunction after I include the .sqrt() function?

Seeking assistance in creating a grid of divs, I am working on finding the square root of the user's input to determine the height and width required to form a square. The code below is what I currently have: $('#size').click(function(){ $ ...

Is it acceptable to replicate another individual's WordPress theme and website design in order to create my own WordPress website that looks identical to theirs?

It may sound shady, but a friend of mine boasts about the security of his WordPress website, claiming it's impossible to copy someone else's layout or theme. However, my limited experience in web development tells me otherwise. I believe it is po ...

In React development, a div (button) is visible, but in the production build, it becomes hidden from

I have been working on a website for my job, and I have added a "Gallery" button on top of two slideshows. Everything works perfectly fine on the development build, but when it comes to the production build, the button doesn't show up for some reason. ...

Is jQuery causing the table to exceed the page width?

I have a table in my HTML document that is displaying too many columns in a single row (~25), causing the table to stretch beyond the size of the page and creating unwanted scrollbars. I am seeking a solution to shrink the content of each column while also ...

Locating a particular table without an identifier

Recently, I've started working on a selenium project and I've encountered a roadblock. The webpage I am dealing with has three tables but I only need to extract data from one specific table. The challenge lies in the fact that all tables have the ...

Pattern to filter out numeric values from a collection

I want to apply a regex pattern to the <input> form element. The pattern should specify a range of numbers that are not permitted as input. For example, let's say I have a list of numbers like {1,4,10}, and any number other than these should b ...

Aligning HTML Headings Vertically with CSS Baseline

I am looking to align two columns of headings to the baseline, with each having a different font size. Additionally, I want one column on the left side and the other on the right side. To achieve this, using display: inline-block will ensure that they are ...

Issue with h2 tag within JQuery's read more feature

How can I modify my jQuery code to wrap the middle text in an h2 tag? I am currently using a code snippet from code-tricks. You can find the original code snippets here: $(document).ready(function() { var showChar = 100; var ellipsestext = "..."; ...

Inheritance of Arrays in Java

Currently, I'm facing some challenges in understanding how to approach a specific problem. My task is to create a class that can store an array with four elements, each having a different method. For instance, the first element needs to inherit data ...

Using CSS to add color to the border of a shape

Is there a way to make only the top, shaped part of this polygon have a 2px blue outline? .graph { clip-path:polygon(0 78%, 9% 67%, 32% 77%, 56% 60%, 69% 30%, 88% 40%, 100% 20%, 100% 100%,0 100%); border:none; height:200px; width:100%; ...

Angular17+ introduces a new feature called the Dynamic Tag Class, providing

Why isn't my navigation bar updating when the page changes? Here is my app.component.html code: <html> <app-navbar></app-navbar> <router-outlet></router-outlet> </html> This is where my navbar.component.html s ...

What is the best way to implement spacing between the navigation bar logo, search bar, and links using flex in Bootstrap 5?

I want to customize the layout of my navigation bar using Bootstrap 5. Specifically, I would like the logo text to be on the left, the search bar in the middle, and the user links on the right. How can I achieve this using Bootstrap 5? <!-- NAVIGATION ...

Having trouble with closing the login window or accessing the HomePage on makeMyTrip.com

As I attempt to automate the MakeMyTrip website using selenium, a snag I've encountered is that the login window ends up blocking all other elements on the page when running tests. One approach I took was trying to click elsewhere on the page in an e ...

Is there a way to show the input value in a different form while still retaining the original value?

When receiving a pagination number from user input, I store it in a variable like so: $html .= "<input type='submit' name='next' value='$next_page_number' />"; Now, I'm looking to replace the displayed text for th ...