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

Event not tracking properly due to missing label in GA event firing

Seeking assistance with a project I'm currently engaged in. I have created an HTML5 video containing a playlist and encountering difficulties setting up multiple labels in GA to track each individual video play. While I found code online, adapting it ...

Switch up the styling of a component by updating its properties with a switch statement

Although there is a similar question, my query has a unique requirement. I have defined the common styles for my button and implemented a function using a switch statement with different properties for various buttons across different pages. However, for ...

Ways to display a different div when clicking on a div?

Good afternoon, I've noticed that this question has been asked numerous times before, but none of the solutions provided seem to work for my specific issue. My problem involves a div with the class .title3. I want another div with the class .Content ...

Is there a way to initiate an Edge animation when an onclick event occurs?

I am interested in incorporating an interactive Adobe Edge animation that activates upon the click of a conventional HTML form button. Could you please guide me on how to achieve this? ...

Leveraging CSS keyframes to create dynamic animations

I am facing an issue with CSS while designing my website. I reached out to the plugin developer for help through a ticket submission, but unfortunately, I have not received a response yet. On my homepage at , I have utilized CSS keyframes to create a text ...

What steps should be followed to incorporate a horizontal scrollbar within the table's header?

I'm currently using Vue and Vuetify to create a unique layout that looks like this: https://i.stack.imgur.com/QBs3J.png The layout consists of a card with three rows: The first row displays the number of items and includes a search bar. The second ...

What is the process behind managing today's Google image of the day?

After coming across the javascript picture control on the Google search page, I became interested in replicating it myself. The feature zooms in on a picture when hovering over it, but I couldn't locate the HTML code they were using for it. Is there ...

Issues are arising with CSS .not(selector) functionality when applied to a span element

One of the challenges I'm facing is formatting a header with a span tag that contains a date and some accompanying text. The goal is to make the text bold without affecting the formatting of the date. In my CSS file, I have tried using :not(cls) to t ...

Designing a navigation system that revolves around a central logo image

I have created a navigation bar that you can see in this image: https://i.stack.imgur.com/eT4TL.jpg Using foundation to construct a website, I have designed the nav bar in the following manner: HTML: <nav class="top-bar"> <ul> ...

Adjust Title Padding Specifically for Mobile Devices

When viewing my blog page on mobile, I noticed that the titles of my blog posts are overlapping with the teasers. To fix this issue, I attempted to add margins to the bottom of the post titles specifically for mobile: https://i.stack.imgur.com/BHi3C.png H ...

How can I target all ul elements except those contained within a div with a specific class using CSS?

In my global.scss file, I have defined global styles for ul elements as shown below: ul { list-style: none; margin: 0; padding: 0; } However, I am trying to find a way to style all ul elements except those within a specific jodit-wrapper class ...

Verify if a personalized angular directive is able to display or conceal an element

I have a custom directive that toggles the visibility of an element based on the value of another service. I attempted to write a test to verify if the directive functions as intended. Initially, I used the ":visible" selector in my test, but it consistent ...

JavaScript providing inaccurate height measurement for an element

Upon loading the page, I am trying to store the height of an element. To achieve this, I have utilized the jQuery "ready" function to establish a callback: var h_top; var h_what; var h_nav; $(".people").ready(function() { h_top = $(".to ...

Using jQuery, learn how to successfully call a selector from dynamic content

I am currently facing a challenge with a table that is generated server-side and then appended to the view page (client-side). Since the table is not directly included in the DOM, I am using the StickyTableHeaders jQuery plugin to create a sticky header fo ...

Is it possible to retrieve values from my model when working with Django Templates and incorporating them in the JavaScript header?

With Django, I have managed to successfully retrieve and display data from my model in the content section of the template. However, I am facing issues retrieving data from the model in the header section of the template. Below is the code --> view.py: ...

Bootstrap Model Footer Button Alignment

click hereI'm facing an issue while adding buttons to the model footer. The buttons are not aligning in line, instead they move to the next line. <div class="modal-footer"> <form method="post" action="admin_view"> ...

What steps can I take to stop search engines from crawling and indexing one specific page on my website?

I'm looking for a way to prevent search engines from indexing my imprint page. Is there a method to achieve this? ...

Unexpected problem with redrawing HTML application in Android WebView

I created a basic nixie clock app using HTML and wrapped it in a WebView for use on Android. It consists of one HTML file, a JS file, a CSS file, and ten digit images. After a few hours, I noticed stripes appearing in the center of the screen where the an ...

What causes the content of a sticky navbar to overflow?

I have a situation where my navbar has two styles (.navbar and .navbar_fixed), but the links in the navbar are not fitting properly. I attempted to remove padding and add left: 0;, however, these adjustments did not work as expected. Any suggestions on how ...

Issues with click events in the navigation menu

How can I make my menu close when clicking on other parts of my website, instead of opening? I know that I should use a click event for this, but when I implemented a click event, my menu encountered 2 unwanted problems: 1- Whenever I clicked on a menu i ...