Incorporating personalized CSS styles into a Bootstrap 4 card

I have been scouring through countless questions and solutions on StackOverflow, but nothing seems to be working for me. While p-5 is doing its job just fine for padding, it applies to all devices. I am in need of specific CSS for mobile devices when it comes to padding. I attempted to add custom CSS by including a custom class infocards within the cards div, but unfortunately, it's not producing the desired outcome. In an attempt to override any competing styling from Bootstrap with my own customized style, I even included the !important declaration.

Note: The page I am constructing is built using Django, and the files are static. These files have been appropriately set up in settings.py.

Below is a snippet from my index.html:

<link rel="stylesheet" href="{% static '/custom.css' %}">
<div class="col-md-6">
  <div class="contacts card p-5 infocards">
    <h3 class="mb-4">Contact Info</h3>
    <div class="row mb-4">
      <div class="col-1">
        <i class="fa fa-user"></i>
      </div>
      <div class="col-9">
        <span>Naman Chauhan</span>
      </div>
    </div>
  </div>
</div>

Take a look at my custom.css:

/* Specific styles for mobile */
.infocards  {
  padding: 10px !important;
}

/* Placeholder for desktop styles */
@media only screen and (min-width: 768px)  {
}

Answer №1

To optimize the css link tag, simply eliminate the / at the end and ensure that you integrate the following line into your template: {% load static %}

<link rel="stylesheet" href="{% static 'custom.css' %}">

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

Utilizing ReactJs to inject CSS styles from the root level

This question may seem simple, but I have been struggling to find an answer even today. I am attempting to import index.css from main.tsx starting from the root. This should allow me to apply styles like: <div className="anyStyle" /> Curr ...

Adjusting Image Size According to Window Resize?

My current issue involves having four images displayed side by side. When the window size is adjusted or viewed on a smaller device, the layout shifts to a line jump (with three images in a row and the fourth one below). What I actually want is for all fou ...

Encoding Emails with Django

After storing Hebrew text in a Postgres DB, my webapp sends it as an email. The text appears fine in the DB, but in the email it looks like gibberish: עובד יקר, זהו טסט של ההתר×ות ...

Deactivate the Submit button when the database field has been populated

My form includes a submit button. The Submit button should be disabled if the "price" for a specific product is already filled: PHP Code <?php $host="localhost"; $username="root"; $password=""; $db_name="ge"; $con=mysqli_connect("$h ...

Floating divs failing to clear properly in Internet Explorer

Encountered a persistent bug that only seems to occur in Internet Explorer. I have set up a jsFiddle to showcase the issue. <div class="container" style="width: 802px;"> <div class="block"></div> <div class="block"></div> ...

When double quotes are used in a string within an HTML input field, they may display as &

Using PHP, I am retrieving data from an SQL database and generating JavaScript code to create an edit button for each entry. The edit button triggers a text input field within a form. When the user clicks on the generated edit button, the text in this inpu ...

CSS problem: alignment issue between text and checkbox

I'm experiencing a CSS style issue where the text box and text are not aligned properly. Can someone assist me in fixing this problem? Below is the code I am using: Thank you for your help. <div> <input type="checkbox" ...

Enhance your SVG progress circle by simply selecting checkboxes

I have a unique system with 5 checkboxes that act as a To-Do list. When I click on each checkbox, the circle's diameter should progressively fill up in increments of 1/5 until all 5 checkboxes are completed. The order in which the checkboxes are click ...

Utilizing Javascript to Open a New Tab from Drupal

I'm attempting to trigger the opening of a new tab when a specific menu link is clicked within a Drupal website. My initial approach was to incorporate JavaScript directly into the content of the page, but unfortunately this method has not been succes ...

The jQuery function .val()/.text() is unable to retrieve information from a particular section of HTML

Implementing HandlebarsJS with PHP and Yii to generate a page. Here is a snippet of the html/handlebars code on the page {{#if embed_link}} <p class='f_hidden_p'> <a href='{{embed_link}}'> {{ ...

Unique Floating Bullet Icons Ascending When Enlarged

I'm currently trying to use a star image as a custom bullet point on an <li> element. However, I'm facing the issue where the bottom of the image aligns with the font's baseline, causing the image to be pushed upwards. Is there any sol ...

Use the Calibri (Body) typeface for the text

I have a div and I'd like to show some text in Calibri (Body) font within it. Any ideas on how to achieve this? Here is the CSS code I've been provided with: .an_account_join_1 { float:left; width:100%; color:#000000; font-fami ...

Customizing WordPress: A Guide to Overwriting the Default Theme CSS

Looking to make changes to the default theme CSS and update it with the necessary styles. How can this be accomplished? Using !important doesn't have any effect. ...

Obtaining the unique identifier of a div element using AngularJS

Recently, I've assigned the id of ng-repeat as objectId, like this: <div class="mainListLabel " ng-if="profile==1" id={{obj.boeId}} ng-repeat="obj in mainList" ng-click="getEmployeeInformation(obj.boeId)">{{obj.boedisplayName}}</ ...

Enabling the autowidth label expands the width of the td element

I am facing an issue where a label inside a table td grows in only one line when its width is greater than the td width. This results in the td expanding and not showing all the text. I would like the label to break into a new line when its width exceeds ...

I encounter difficulties with perspectives

Below are the models I am working with: Class Category(models.Model): name = models.CharField(max_length=150, unique=True) description = models.CharField(max_length=250) def get_absolute_url(self): return reverse('categories_url& ...

Can the browser tabs automatically detect when a user logs out?

When I have multiple tabs open of the same website in a browser, I wonder how other windows can detect when a user has logged out. My development setup involves using Python/Django. The method I am currently implementing is: function user_checking(){ ...

JQuery's window resize function is only triggering once instead of firing at every resize event

I am working on setting up a jQuery function to ensure that the navigation bar functions correctly based on the window width. Here's what I want to achieve: If the screen width is greater than 949px, I would like a function to be initiated that allows ...

Utilizing shared components with withStyles and material ui components

I'm currently working on a project using React, TypeScript, and Material UI. Here is the layout I have: <MuiThemeProvider theme={muiTheme}> <My Component/> </MuiThemeProvider> Within my component, the code looks something ...

Having trouble locating a div element with Selenium

<div class="panel-menu-container dropdown open"> <ul class="dropdown-menu dropdown-menu--menu panel-menu" role="menu"> <li> <a> <div class="css-wf08df-Icon"> <svg xmlns="http://w ...