Customizing ExtJS 4's CSS reset specifically for tailored HTML inside components

I am currently in the process of upgrading an existing application from Ext 3.x to 4. I have successfully enabled Ext's scoped reset CSS option to prevent Ext from applying its CSS reset to my entire application. However, I am now facing a new issue. My application heavily relies on hardcoded HTML and CSS styles, much of which is contained within Ext components such as panels and tab panels. Since this HTML is a descendant of the Ext components' elements, it inherits the CSS reset styling, causing conflicts with the custom styling of the non-Ext HTML.

There are two specific CSS rules that are causing problems:

.x-border-box .x-reset, .x-border-box .x-reset * {box-sizing: border-box;-moz-box sizing: border-box;-ms-box-sizing: border-box;-webkit-box-sizing: border-box;}

Dealing with the box-sizing property was manageable by creating a custom reset wrapper class that reverted the box-sizing back to 'content-box' and applying it to the topmost wrapper element in the custom HTML. The rule looks like this:

.my-reset, .my-reset *, .x-reset .my-reset *, .x-border-box .x-reset .my-reset * {    box-sizing: content-box;    -moz-box-sizing: content-box;    -ms-box-sizing: content-box;    -webkit-box-sizing: content-box;}

However, the other CSS rule is more challenging to address:

.x-reset html, .x-reset body, .x-reset div, .x-reset dl, .x-reset dt, .x-reset dd, .x-reset ul, .x-reset ol, .x-reset li, .x-reset h1, .x-reset h2, .x-reset h3, .x-reset h4, .x-reset h5, .x-reset h6, .x-reset pre, .x-reset code, .x-reset form, .x-reset fieldset, .x-reset legend, .x-reset input, .x-reset textarea, .x-reset p, .x-reset blockquote, .x-reset th, .x-reset td {margin: 0;padding: 0;}

This particular rule poses a challenge because the different elements in my custom HTML do not all require the same margin and padding settings. Overriding these styles in the same manner as the box-sizing property is not feasible. The high specificity of these selector rules gives them precedence over many of my custom CSS styles. For example, the ".x-reset div" selector's margin/padding styles override those set by a rule like ".my-cool-class { padding: 5px; margin: 5px; }".

To address this issue, I could increase the specificity of my custom CSS rules by either prefixing class selectors with the element type they target (e.g., "div.my-cool-class") or prefixing the rules with .x-reset (e.g., ".x-reset .my-cool-class"). However, both options would require extensive manual updating of existing custom CSS, increasing file size and reducing modularity of CSS classes.

Is there a solution through Ext's settings or another CSS method that I may have overlooked that can elegantly solve this problem with minimal overhead?

Answer №1

To make your CSS more flexible, consider removing the specificity from the extjs css. This way, any CSS included afterwards will take precedence.

Instead of:

.x-reset html, .x-reset body, .x-reset div, 
.x-reset dl, .x-reset dt, .x-reset dd, 
.x-reset ul, .x-reset ol, .x-reset li, 
.x-reset h1, .x-reset h2, .x-reset h3, 
.x-reset h4, .x-reset h5, .x-reset h6, 
.x-reset pre, .x-reset code, .x-reset form, 
.x-reset fieldset, .x-reset legend, .x-reset input, 
.x-reset textarea, .x-reset p, .x-reset blockquote, 
.x-reset th, .x-reset td {
  margin: 0;
  padding: 0;
}

Use:

html,  body,  div, 
dl,  dt,  dd, 
ul,  ol,  li, 
h1,  h2,  h3, 
h4,  h5,  h6, 
pre,  code,  form, 
fieldset,  legend,  input, 
textarea,  p,  blockquote, 
th,  td {
 margin: 0;
 padding: 0;

}

This adjustment will ensure that your customized CSS takes effect.

.myPadding{
  padding: 10px
}

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

Guide to implementing a seamless Vue collapse animation with the v-if directive

Struggling with Vue transitions, I am attempting to smoothly show/hide content using v-if. Although I grasp the CSS classes and transitions involved, making the content appear 'smoothly' using techniques like opacity or translation, once the anim ...

Is it possible to have the navigation bar (bootstrap) appear on top of my slider as the default setting, without taking up additional space?

I'm encountering a rather simple issue that's giving me some trouble. I'm currently working on a website design using Bootstrap, and initially, there were no image sliders included by default. After integrating an image slider, I noticed th ...

Is there a way to rearrange the tabs so that the first tab is at

Is there a way for me to align with the others without being stuck below #first_tab in the code? I'm having trouble figuring it out on this website: Your assistance would be greatly appreciated! Thank you in advance! CSS Code: #first_tab { ...

Issue observed in Angular Material: mat-input does not show background color when in focus mode

https://i.stack.imgur.com/eSODL.png Looking for a solution regarding the mat-input field <mat-form-field> <input class='formulaInput' matInput [(ngModel)]='mathFormulaInput'> </mat-form-field> The blue backg ...

Is the hover effect malfunctioning, even though the correct style has been applied?

I'm currently working on a simple design, but I've encountered an issue. When I hover over the number blocks (1, 2, etc.), my hover effect doesn't seem to work. My intention is to hover over the list item and change the entire digit text fro ...

Different ways to position 3 images side by side and ensure they are centered on the

I am struggling to center 3 images horizontally on my webpage. Despite aligning them in a row, I cannot seem to achieve the desired centering effect. I have tried various methods to center the images, but nothing seems to work effectively. My goal is to ...

Exploring GitHub's sleek popup: in search of CSS styling!

Exciting news from Github: they have introduced a new feature called maps. This feature is developed using Leaflet, and it has some unique custom CSS for the pop-up design: I'm eager to implement something similar on my site, but I'm having trou ...

Conceal the div element if the screen size drops below a certain threshold

Is it possible to hide a div element when the browser width is less than or equal to 1026px using CSS, like this: @media only screen and (min-width: 1140px) {}? If not, what are some alternative solutions? Additional information: When hiding the div eleme ...

Why is it that consolidating all my jQuery plugins into one file is ineffective?

Prior to this, I included the following scripts: <script type="text/javascript" src="{{MEDIA_URL}}js/plugins/json2.js"></script> <script type="text/javascript" src="{{MEDIA_URL}}js/plugins/jquery-msdropdown/js/jquery.dd.js"></script&g ...

Creating a horizontal scrollbar in columns using Bootstrap can be accomplished by adjusting the CSS properties

Having a container created with boostrap: https://i.sstatic.net/bqAuf.png The question at hand is how to implement horizontal scrolling in order to maintain the aspect ratio of the initial image within the container on phone resolutions. Here is the con ...

What is the best way to change the folder name when hovering over it?

Typically, my website displays categories with images from the /thumb-min/ directory. For example, 95-IMG_6509.JPG is loaded like this: /thumb-min/95-IMG_6509.JPG When I navigate to the details page, it loads the image from: /thumb-medium/95-IMG_6509.JP ...

Flexbox parent div experiencing overflow due to horizontal margins protruding beyond the boundaries

Experiencing unexpected margin behavior with flex and seeking help for clarification. Here is a simple HTML structure I am using: <div className="dashboard"> <div className="dashboard__inner-container">Inner Container</div> </di ...

Folded Corner Div using only CSS

I've been tirelessly experimenting with countless online methods, but I can't seem to make anything work. There's a div that needs to be flexible in width and height, positioned on a tile-able background image with a 1px border. The challe ...

Is there a way to have two SVG files displayed on a single HTML page at the same time

Currently, I am facing an issue with my graphs. I have a line graph and a boxplot, but the boxplot is appearing below the line graph when I want it to be next to it. Any suggestions on how I can achieve this layout? Thank you! I attempted to use 2 differe ...

Issues with styling SVG when using the `<use>` element

I am currently faced with a challenge involving CSS, where I need to modify the size and color of an SVG element that is being displayed using <use>. The specific SVG in question is as follows: <svg xmlns="http://www.w3.org/2000/svg" width="24" h ...

Is there a way for me to recreate the appearance of the outline and labeling found in Material-UI's outlined textfield?

Can anyone help me figure out how to hide the border behind the title text in an outlined textfield from Material-UI that I am trying to imitate? In the image below, you can see "Due Date/Time" taken from Material-UI library where the title hides the bord ...

Parent whose height is less than that of the child element

I'm working on creating a side menu similar to the one on this website. However, I'm facing an issue with the height of the #parent list element. I want it to match the exact same height as its content (the #child span - check out this jsfiddle). ...

Safari's flexbox wraps the final column on the top row

When viewed in Safari and some other iOS based browsers, the last column of the first row wraps to the next line. Safari: https://i.sstatic.net/FhYyn.jpg Chrome / Others: https://i.sstatic.net/Vkvr0.jpg Code: .flexthis { display: -webkit-box; d ...

Can we keep a portion of the input placeholder content?

The input box below accepts values in percentage form. To indicate this, I have set a placeholder that says Percentage (%). https://i.sstatic.net/LJ1ee.png My goal is to automatically add a % symbol to the value as soon as it is entered into the input fi ...

Inconsistency in field generation in WordPress Contact Form 7 causing issues

After utilizing the WordPress plugin Contact Form 7 to put together a straightforward questionnaire, I discovered that two fields, Your Birthday and Your Email, were mistakenly generated on top of one another in the final output. You can take a look at th ...