Is there a way to update or modify the media queries set in the Bootstrap CSS file

I don't want the media queries defined in the Bootstrap CSS to override my custom CSS when the user resizes their window.

Here is my HTML code:

<div class="row">
<div class="col-xs-6">
<dl class="dl-horizontal dl-horizontal-info custom">
<dt>item 1</dt>
<dd>description 1 </dd>
<dt>item 2</dt>
<dd>description 2</dd>
<dt>item 3</dt>
<dd>description 3</dd>
<dt>item 4</dt>
<dd>description 4</dd>
<dt>item 5</dt>
<dd>description 5</dd>
</dl>
</div>
<div class="col-xs-6">
<dl class="dl-horizontal dl-horizontal-info custom">
<dt>item 11</dt>
<dd>description 11 </dd>
<dt>item 12</dt>
<dd>description 12</dd>
<dt>item 13</dt>
<dd>description 13</dd>
<dt>item 14</dt>
<dd>description 14</dd>
<dt>item 15</dt>
<dd>description 15</dd>
</dl>
</div>
</div>

Here is my CSS:

@import url("http://maxcdn.bootstrapcdn.com/bootswatch/3.2.0/cerulean/bootstrap.min.css");
@import url("http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css");

.custom > dt{width:120px;}
.custom > dd{margin-left:130px}

http://jsfiddle.net/afLka00x/

When I resize the window to less than 768px, the media query from Bootstrap CSS overrides my custom CSS, causing dt and dd to align vertically instead of horizontally.

How can I prevent this?

I found that the following code in the Bootstrap.css file is causing the issue:

CSS

@media (min-width: 768px) {
  .dl-horizontal dt {
    float: left;
    width: 160px;
    clear: left;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .dl-horizontal dd {
    margin-left: 180px;
  }
}

So, I modified the code in my custom.css as follows:

CSS

@media (min-width: 768px) {
  .dl-horizontal dt {
    width:120px;
  }
  .dl-horizontal dd {
    margin-left:130px
  }
}

However, the alignment issue persists even after resizing the window.

I want my dl to maintain horizontal alignment regardless of window size.

and not like this

Answer №1

When a user resizes their window, I want to make sure that my custom CSS takes precedence over any media queries defined in Bootstrap CSS.

Rest assured, your custom CSS will not be overridden by Bootstrap.

Bootstrap doesn't actually "override" your styles. Instead, it adds a float:left property when the viewport width is above 767px, which achieves the desired behavior:

@media (min-width: 768px)
  .dl-horizontal dt {
    float:left;
  }
}

Below 768px, this styling is not present, so the default browser stylesheet will be applied instead.

If you want the dt element to always float left, even below 768px, you will need to include that in your own CSS rules:

.custom > dt{
  float:left;
  width:120px;
}

http://jsfiddle.net/afLka00x/1/

Answer №2

Give this a shot in your Personal.css file

@media (min-width: 768px) {
        .horizontal-layout > dt{  size: 120px!important; flow: left;
      clear: both;}
}

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

Unpredictable characters within CSS class titles

I've observed an interesting pattern on certain websites like tray.io, asana, and Facebook. When you inspect their CSS class names, you may come across random combinations of characters, such as: <header class="Header_XSDsdksdXKkSDD">..</Hea ...

Warning from Google Chrome: Ensure password forms include optional hidden username fields for improved accessibility

Upon visiting the "reset password" route of my single-page application and checking the Chrome browser console, I am presented with a warning message: [DOM] Password forms should contain (optionally hidden) username fields for accessibility: (More info: g ...

Troubleshooting Compatibility Issues: JavaScript Function Works in Chrome but not in Internet

After collaborating with fellow coders to develop info boxes using HTML, CSS, and JavaScript, I have come across an issue with the hover functionality not working properly in Internet Explorer. Interestingly, everything functions flawlessly on Google Chrom ...

Is there a way for me to view the contents within the box?

Hey there! I have a question about how to access the content inside this mysterious box "" within the style sheet. For instance, I am curious to find out the link of the image: .facebookicon::before { content: ""; } ...

Limit 4 items per row in a flexbox layout with automatic width

https://i.sstatic.net/UaD6R.png I am currently using tables to display my items, but I want to switch to flexbox. However, when I tried using flexbox, the item widths were not dependent on their content. Any suggestions on how I can achieve this? Thank you ...

Scale transformation causing text display problem in Firefox

Using css-transforms for scaling text on hover to another size is working smoothly in all browsers, except for Firefox. The font in the scaled element appears slightly unsharp initially, then sharpens after a few milliseconds. You can test and see this is ...

Scrolling automatically

I'm experimenting with creating a typing effect using JavaScript and the typed.js library, found here: My approach involves using a div as a container. However, I've encountered an issue - when the text reaches the height of the div, scroll bars ...

What is the best way to incorporate a changing variable within an htmx request?

One of the endpoints in my site requires an ID to be passed as a parameter. For example: mysite.com/product/{id}?limit=5 I'm wondering how to pass the 'id' variable in the hx-get attribute. I can utilize AlpineJS or vanilla JS for this tas ...

The perplexing problem of scrolling in Dojox/mobile/scrollableview

I've noticed some scroll issues with the dojox/mobile/ScrollableView (version 1.10+) in my cordova application, specifically on Android phones. This problem seems to be affecting other widget-based architectures and even some store apps as well. I wou ...

Increasing the position of a div using Django

Currently, I am working on a website project for a client who wants to incorporate a unique feature which involves having a very wide but not very tall page. One challenge I am facing is the placement of a list of objects on the page in a way that they co ...

I am having trouble aligning the unordered list in the center

My struggle lies in centering the ul element which serves as a menu. Despite trying various CSS properties such as margin: 0 auto;, text-align: center;, and adjusting the margin value, I am unable to achieve the desired result. This is the CSS code I have ...

Aligning content with CSS styling

I am facing a challenge with aligning buttons in three different td tags, as the text content within each varies. I want the buttons to line up evenly regardless of the amount of text present. Is there a solution that does not involve setting a fixed parag ...

Removing the gap between the clicked point and the draw point in Html5 canvas

To better understand my issue, please refer to the image linked below: In the image, you can see that when I scroll down and click on the canvas to point a position, it creates space between the clicked point and where the line is drawn. Below is the cod ...

Firefox is having trouble loading SVG files

For some reason, the SVG image is loading on all browsers except for Firefox. I checked the DOM but couldn't find the code. Just to clarify, I am serving the page from Tomcat 9.0.34 <kendo-grid grid-options="gridOptions"> <img src= ...

Build a table with consistent columns and flexible rows utilizing CSS and HTML

Just starting out with CSS/HTML and looking for guidance on creating a table with a variable number of rows. Any tips on how to achieve this using CSS? I'm aiming to replicate a table with a similar structure, but struggling to figure out how to defin ...

Creating a progress bar that includes hyperlinks: A step-by-step guide

Currently, I am in the process of developing an application form that consists of 9 pages of questions. Initially, I had implemented a progress bar which indicated completion by filling up 1/9 for each page completed. However, I have been informed that thi ...

How to position a div in the center of another div using HTML

I'm struggling to center the bottom div within a container that includes 3 other divs. Despite trying multiple solutions found online, nothing seems to work. This task should be simple, but for some reason, I can't get it right. .container { po ...

"Using jQuery to dynamically change the src attribute of an iframe, the change persists even after

There's a strange issue bothering me. On a single page, I have a menu and an iframe. Whenever I click on a menu button, the jQuery code changes the src attribute of the iframe. Initially, when the page loads, the iframe is supposed to display "Home". ...

Combining CSS, jQuery, and HTML into a single .html file would allow for seamless integration

I've been searching extensively, but I haven't been able to locate exactly what I need. My goal is to merge my jQuery and CSS into a single .html file, but I'm struggling to get the jQuery functionality to work. Although I have experience wi ...

The successful execution of $.ajax does not occur

Starting out with ajax, I wanted to create a simple add operation. Here is the code that I came up with: HTML: <!doctype html> <html> <head> <title>Add two numbers</title> <meta content="text/html;charset=utf-8" h ...