Adding Information to a Material Design Card

Currently, I am delving into frontend development and honing my CSS skills. In my latest project, I have incorporated a mat card which can be viewed in the linked image https://i.sstatic.net/TEDcg.png.

Below is an excerpt of my code:

   <div class="col-4">
                        <mat-card class="card">
                                <div class="header">
                                    <div class="content1">Content of My header</div>
                                    <div class="content2">Content of My header</div>
                                </div>
             
                                <button mat-button>MyButton</button>
                        </mat-card>
                    </div>

.card {
  background-color: red
  height: 47vh;
  display: flex;
  top: 2.5rem;
  flex-direction: column;
  right: 2rem;
}

.header {
  background-color: red;
  padding: 3% 0% 1% 3%;
}

Notice how the Header section has empty spaces around it. I aim to completely cover the header with a red color without these gaps. How should I proceed?

Answer №1

Have you attempted using margin:0 within the .card class?

Answer №2

If you want to ensure consistent styling across different browsers, I suggest including a reset style file on your website. This will help avoid any potential discrepancies in the appearance of your site in the future. Here’s a simple way to incorporate this:

HTML:

<link rel="stylesheet" href="/path/to/reset-css/reset.css" />

CSS:

@import '/path/to/reset-css/reset.css';

For instance, within your code:

@import 'https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css';
.wrapper{
  height: 47vh;
  border: 1px solid black;
}

.header{
   background-color: blue;
  display: flex;
  flex-direction: column;
  height: 90%;
}
  <div class="wrapper">
        <div class="header">
            <div class="content1">Content of My header</div>
            <div class="content2">Content of My header</div>
        </div>

        <button>MyButton</button>
    </div>

Answer №3

Update the .card styling as follows:

  .card {
    background-color: blue;
    height: 50vh;
    display: grid;
    top: 3rem;
    justify-content: center;
    right: 2.5rem;
    padding: 0; <------This line was added
  }

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

The battle between percentages and pixels in fluid design

I am looking to create a flexible layout and would like to achieve the following: width:100%-200px; This means having a div that contains content, referred to as div id="content", with a fixed margin on each side. I have attempted to place the div id="co ...

What is the best method for adding anchors or appending items in aspx pages?

I have created code for an image gallery on my webpage, "gallery.aspx". The situation is that I have an external aspx page with various links. When a user clicks on one of these links, I want them to be redirected to the image gallery but to a specific ima ...

Saving a picture to local storage with the file input type in ReactJS

I am attempting to save an image in the browser storage once a user selects an image from their computer. <div className="add_grp_image_div margin_bottom"> <img src={img_upload} className="add_grp_image"/> <input type="file" class ...

interaction & portal

I am currently managing a website that includes an iframe. Both the main site and the embedded site within the iframe are verifying the $_SESSION["login"]. Therefore, if the session expires, the user will be automatically logged out. The issue I'm fa ...

Update the background color of an li element upon clicking

Is there a way to change the background color upon clicking on the li anchors? <div class="text-center row"> <ul class="col-md-12 secondNav"> <li class="navbar-brand nav-item" style="margin-right: 9%"> <a href="#" >& ...

Is there a way to customize the color of a React component from a different source?

I am currently utilizing a React component library called vertical-timeline-component-react. <Fragment> <Timeline> <Content> <ContentYear startMonth="12" monthType="t ...

Alter the color of the span text without affecting the :before or :after elements

Can you change the text color of a span without affecting its :before and :after colors? Is it possible to modify the color of the main text in a span element without altering the colors of the elements that come before and after it? Here is an example o ...

What is the best way to position my div outside of the wrapper while keeping the text inside?

For example: https://i.sstatic.net/UyhOl.png I want the blue text that says "join our discord server" to extend to 100% width when it's placed inside the wrapper. The reason it's inside the wrapper is to ensure the text matches up perfectly with ...

Implementing the Fixed Header feature in DataTables - A Step-by-Step Guide

I'm encountering an issue with implementing a fixed header for my table using the DataTables plugin. Despite previously asked questions addressing similar problems, I am still unable to resolve it. I suspect that conflicting CSS or missing CDN links c ...

How can I send form data using libcurl in C++ for a particular form?

How can I post and submit form data using libcurl and C++ for the form below? <form id="loginContainer" class="controllerContainer" action="/j_spring_security_check" method="post"> <h2>Login</h2> <hr> <fieldset> <div ...

A guide on verifying the username, password, and chosen role from a database through the use of javascript/ajax or alternative validation methods

If the user's name, password, or role is incorrect, I want to display an error message using validations like AJAX/JavaScript. index.php <html> <head> </head> <body> <style> body { wi ...

Find all paragraphs with the CSS property "background-color" using JQuery

My task involves modifying the CSS of a paragraph tag that has a background color of #aaddff. The code I have written seems to be missing something, as the border is not appearing as expected. Should I use element.style or is there a different approach I ...

What is causing the resistance in changing the color of my current navigation items?

I've encountered a small challenge with my header section. Despite multiple attempts, I'm struggling to change the color of the 'current' menu item. It seems that overriding Bootstrap's default color is proving to be more difficult ...

What is the process for including an icon in Material-UI Select component?

I am trying to figure out how to add a location icon to React Material-UI Select options. Unfortunately, I couldn't find any specific option for this in the API docs. Can someone please assist me with this task? Your help would be greatly appreciated. ...

Navigating Up a Directory with JQuery

Is there a way to navigate up one directory level in my jQuery code? The code below is referencing a folder named "uploads" on the C drive, but I can't find any mention of "uploads" in my HTML. How does it know to look there? And how can I go back to ...

Tips for adjusting the font size of a Chip using Material-UI

I am using a widget called Chip const styles = { root:{ }, chip:{ margin: "2px", padding: "2px" } } const SmartTagChip = (props) =>{ const classes = useStyles(); return( <Chip style={{color:"white&q ...

What is the best way to implement conditional styling in Vue.js?

Looking to incorporate a conditional style into my Component. Here is my component: <site-pricing color="primary" currency="$" price="25" to="/purchase" > <template v-slot:title>Complete</templat ...

Access the configuration of a web browser

I am in the process of creating a website where I need to prompt the user to enable JavaScript. Is there a way for me to include a link to the browser's settings page? Here is an example: <noscript> <div>Please enable JavaScript &l ...

The media query in Bootstrap v4 does not seem to be functioning properly when using the device tool in

Utilizing a div with the Bootstrap classes: "d-none d-md-block", I anticipate the div to be hidden on smaller devices. Yet, while in Chrome Developer Tools and utilizing the device toolbar it seems to disregard the dimensions.. With Laravel version < 4, ...

Attempting to serialize a form using Ajax and jQuery

I am facing an issue with submitting user input from a modal using jQuery and AJAX. The problem is that the AJAX call is not capturing the user input. Even though the AJAX call is successful, when I check on the server side, the user input appears to be bl ...