How to lessen CSS
Tags: css
Problem :
<div id="tt">test1</div>
<div id="blabla">test2</div>
<div id="test">
<div id="blabla">test3</div>
<div id="tt">test4</div>
</div>
<style>
#tt {color:blue;}
#blabla {color:green;}
#test #tt, #test #blabla etc... {color:red;}
</style>
Is there a way to avoid repeating #test?
Thanks ;)
Solution :
Depends on what you want to do. If you want all the text nodes to be red and the parent element is #test
, then you just need #test {color:red}
. If you need to be more specific, and give a color only for a child, then you can use .child {color:blue}
, but if you want to color a child of #test
, then you will need to specify the ancestor descendant, in other words #test .child {color:green}
Edit
Example according my comment http://jsbin.com/udoya3
CSS Howto..
$this->view->headLink()->appendStylesheet('/css/ie.css', 'screen', 'IE'); $this->view->headLink()->appendStylesheet('/css/ie6.css', 'screen', 'IE6'); ...
div.divmainimg { position: relative; } div.divmenu { position: absolute; top: 0; left: 0; } Consider changing the class names to mainimg and menu, respectively....
You can explicitly add a CSS class to custom controls using the CssClass property: .static-position { position: static; } <telerik:RadComboBox ID="radcbFrom" CssClass="static-position" ...> .... </telerik:RadComboBox> Update: We found the solution...
I think when user zoom in/out their browser display, it is automatically makes your site element became bigger/smaller. Maybe you need to redesign your site. Tell us what kind of...
Can you try this, $document =& JFactory::getDocument(); $document->addStyleSheet('your css url here ');// for css $document->addScript('your jaavscript url here ');// for script Ref: http://docs.joomla.org/J3.2:Adding_JavaScript_and_CSS_to_the_page...
Maybe like this? HTML <div class="line"></div> CSS div.line { width: 75%; height: 1px; margin-left: 25%; background: red; } Demo Try before buy...
[..]and near this element I have a div with this style near is ambiguous and makes it sound like your issue is due to a misinterpretation of stacking context...
Nevermind. I figured it out. It has to do with the display CSS property. Angular's ngShow directive applies display: none to the element when it hides it. This property would...
You can make your text automatically change size along with the size of the window by defining your font-size in vhs or vws. For example: #mystyle p { font-size: 2vw;...
The CSS content property is used with the :before and :after pseudo elements and shouldn't be used in the way you are intending. Instead, this sounds like a good use...
It's kind of cheesy, but since you're using javascript anyway, try this after you changed the className: document.body.style.display = 'none'; document.body.style.display = 'block'; This will re-render the layout and often...
I think you want to float the icon: .icon-small i { float: left; margin-right: 10px; /* ... */ } And for good measure: .icon-small + p { clear: left; /*...
Check out this fiddle for a 99.9% working solution. You can dynamically calculate the width of the div and set them. However, One the div elements become too small, the...
There isn't a jQuery function for this, but the static method window.getComputedStyle works for all modern browsers and IE9. var cachedStyle = window.getComputedStyle(domElement); // later $(domElement).css(cachedStyle); Update: If you only...
The conclusion that I have come to is that this may not even be possible. I went with an alternate method of using jQuery.resizable to do it manually instead.
To add border around each individual post you can try adding this to the class .post: .post { border: 1px solid; } ...
You can add CSS files to your iFrame using Javascript: var cssLink = document.createElement("link") cssLink.href = "file://path/to/style.css"; cssLink .rel = "stylesheet"; cssLink .type = "text/css"; frames['iframe'].document.body.appendChild(cssLink); You just have to...
Have you tried the following : How to define bold, italic using @font-face ? The @font-face property allows you to specify for which styles to apply the font....
you can use the % unit for width of img tag. So it can be scaled according to browser window. And another method is to use following media queries /*...
I've done this a few times before with several different solutions. What I found the most useful is using the ::before selector. You inherit every background-property you specified and apply...
You need to add outline:none; to a img as well.
No. Flexbox does not offer a way to style specific lines in a multi-line flex container. Flexbox does allow flex items to resize based on their flex-basis value. http://codepen.io/cimmanon/pen/GKEfD .flexwrap...
Here's some jQuery performance rules that gives some tips on how to set up ids and classes.
Try this: (you should be aware of the parent wrapper element) body > *:last-child > span:last-child{ color: red; } Working Fiddle...
See this example: http://dabblet.com/gist/5450624 (Tested on Firefox 20/Chrome). I used a 400x400 jpg image and I've adjusted its top/left offset. relevant CSS div { position: relative; width: 0; height: 0;...
I have updated your fiddle. http://jsfiddle.net/K2RAt/1/ changed $(this).next(".laptop").hide(); to $(".laptop").hide(); This will work for you....
var fileToUse = (window.location != window.parent.location) ? "file1.css" : "file2.css"; $('<link rel="stylesheet" type="text/css" href="' + fileToUse + '"/>').appendTo("head"); I can't test it right now but that should do it....
Add the child selector >: .hasChild.top > a:after { } .hasChild.sub > a:after { } ...
I am not sure if I understood you correctly, but you can have a generic rule for all checkboxes followed by a more specific rule for a specific checkbox (which...
Building upon my comment on your question. If you have control over how the HTML for the menu is generated, a workaround would be to add an extra class to...