If I want override inline css i must use !important or javascript.
But if I want to override, for example, inline width without important I can use max-width or min-width
Is there some way to override inline
overflow:hidden
Using CSS
You can override the inline style using !important keyword like below. The inline style background green is override with other color through the class style using !important keyword.
.test {
background-color:#ff00ff !important;
}
<div class="test" style="background-color:green">
<h1>
Sample
</h1>
</div>
Using Javascript
The same you can achieve using JavaScript also.
document.getElementById('test').style.backgroundColor = '#fff000';
<div id="test" style="background-color:green">
<h1>
Sample
</h1>
</div>
You can override the inline style using !important keyword
.overwrite_css{
background-color: blue !important;
}
<div class="overwrite_css" style="background-color: red;font-size: 25px;">
<h2>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
</h2>
</div>
Still not able to override it then try this one
Note: Using !important ONLY will work here, but I've used overwrite_css[style]
selector to specifically select div having style attribute
The example uses [style] (the attribute selector) to show us that the CSS is targetting the div with the “style” attribute.
.overwrite_css[style]{
background-color: blue !important;
}
<div class="overwrite_css" style="background-color: red;font-size: 25px;">
<h2>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
</h2>
</div>
You can only override inline css with
!important
or you have to use javascript to do so.
If you want to change inline css you should use js, you can override through !important tag but it has high priority so it may affect other css style...
So it's good to use js instead of !important tag.
Related
Like in this example below, is it possible to make the second column have more items than the first one?
Yes it is possible.
It is a work-around though. If you are breaking text into a no of columns, you can simple use <br> tag in the first column to push more content into the second column.
If you are using a no of images in a list as an example, lets say 5, by default the first column will house 3 and the second column will house 2. But you can change that by adding gap between the 2nd and 3rd item using margin.
These methods though working, are not a good practice.
Hope you found this helpful!
Well here's how I would do it.
After all the other styles, I used the direction property to specify how the box uses up it's space. The default value is ltr (left-to-right), but setting it to rtl (right to left) forces the box to fill up the right side of the element firstly.
It you're planning on using text in containers like that, you should use the text-align: left declaration to force the text to align to the left.
.container {
display: flex;
align-items: center;
flex-flow: column wrap;
height: 100px;
padding: 20px;
column-count: 2;
direction: rtl;
margin-bottom: 1rem;
}
.container.text {
text-align: left;
}
.bar {
display: inline-block;
width: 6rem;
height: 10px;
margin: .25rem 0;
border-radius: 5rem;
background-color: black;
}
<div class="container">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</div>
<div class="container text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ac tincidunt vitae semper quis lectus. Faucibus interdum posuere lorem ipsum dolor. Nam aliquam sem et tortor consequat id porta
nibh venenatis. Enim ut sem viverra aliquet eget sit amet.
</div>
I have two long introductory articles on the home page. They are only necessary for first time visitors so I want to simply show a summary with the option to expand it.
My issue is that as the articles are long, the 'HIDE' option needs to be at the END of the article. This makes the radio/input option limited unless I can figure out a way to activate it from the end. Is there a way to trigger it using only css?
The site is CSS only. I am not concerned with outdated browsers but I would like it to be SEO friendly (readable) and not have any security triggers (hence no scripts).
I've read through everything I could find, but the options either require the same trigger to activate show/hide (not user friendly in my case as user would have to search for it within the article) or JS. I've tried playing with links and buttons to no avail. I've considered using a dialog box, but that also requires JS to activate. Modal pop-up is a possibility, but I am not sure how that reacts with pop-up blockers so I have it as a last resort.
The other responses are somewhat dated, so I was hoping that there are some techniques that now have wider support that could be considered.
Here is the jsfiddle.
/*OPTION 1*/
#More,#Art1 {display: none} /*hides checkbox and 2nd part of article */
#More:checked~#Art1 {
display: block;
}
/*Trying to get it to close: */
#Less {
display: none}
#Less:checked~#Art2 {
display: none;
}
/* OPTION 2 */
.option2 {
background-color: yellow;
}
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.text2b {
background: #bbb;
border-radius: 5px;
width: 70%;
position: relative;
transition: all 5s ease-in-out;
}
.text2b .close {
transition: all 200ms;
font-size: 16px;
font-weight: bold;
text-decoration: none;
color: #333;
}
<!--OPTION 1 -->
<p>OPTION 1. RADIO BUTTONS. The beginning of an article. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.2B continued.
</p><input type=checkbox id="More"><label for="More">MORE</label>
<div id="Art1">
<p>
Second part of Lorem. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam. The End of Option 1.</p>
<input type=checkbox id="Less"><label for="Less">LESS</label>
</div>
<!--OPTION 2 -->
<div id="option2a" class="option2">
<p>OPTION 2. MODAL OPTION. The beginning of an article. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.2B continued.
</p>MORE
<div id="option2b" class="overlay">
<div class='text2b'>
<p>
Second part of of MODAL OPTION. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam. The end. </p>
<a class="close" href="#">CLOSE</a>
</div>
</div>
<p>
Other stuff... Meant only to check positioning of Modal.
</p>
The fiddle shows this option and a modal version I have been playing with. Other ideas that fit the prerequisites are welcome.
I had just about given up on this technique, but surprisingly, there is a solution.
Evidently you can tie multiple labels to one form control. So by simply adding a label (not input field) for "MORE" at the END of the article, it actually triggers the original input. No extra CSS required.
Works like a charm in FF and while I cannot see why there would be an issue in other browsers, I have not had an opportunity to verify.
Full credit for this brilliantly simple solution goes to Beverleyh at CSS-Tricks:
CSS-Tricks Forum
I hope this helps others. I was not really aware of this feature but could see many uses for it.
I'm working on a page right now which has blocks of text set in border boxes, and the text within these is styled.
Basically, the main problem I'm having is that within the styled <p> tag containing the border styling, when I try to break the text into another paragraph, the text after the </p> jumps outside of the box. I've tried adding the <p> in all kinds of different places but it just won't do what I want, and I can't find any tutorials on how to add extra paras within a paragraph styled with a border. Sample code below... this box was easy because there is only a single short paragraph. The rest of the page has multiple paragraphs that all need to fall within the border box.
Can anyone please help?
<p style="border: solid 3px #4D545E; padding: 6px;">
<strong style="color: #c01d21;">Book your Christmas party</strong>
on any Monday-Thursday in November – and all your guests will receive a complimentary Sorbete al Cava cocktail.
<br>
<a style="text-transform: uppercase;line-height: 38px;text-align: center; " class="link" href="http://www.manchesterconfidential.co.uk/b.aspx?b=6980" target="_blank">
<strong>Click to book a table</strong>
</a>
Or call <strong>#### ### ####</strong>
</p>
If i understand what you are saying, i have mad a snippet code for you here so that you can check it out, if it suites what you want, you can use it or try to explain more about what you want.
.wrapper{
border: solid 3px #4D545E; padding: 6px;
}
.center{
text-align:center;
}
<div class="wrapper">
<p><strong style="color: #c01d21;">Book your Christmas party</strong> on any Monday-Thursday in November – and all your guests will receive a complimentary Sorbete al Cava cocktail.</p>
<p class="center">
<a style="text-transform: uppercase;line-height: 38px;text-align: center; "class="link" href="http://www.manchesterconfidential.co.uk/b.aspx?b=6980" target="_blank"><strong>Click to book a table</strong></a></p>
<P class="center">
Or call <strong>#### ### ####</strong></p>
</div>
following up on Jerry's answer above, to add multiple paragraphs should be as simple as adding<p>tags (assuming this is what you are looking for).
code wise, it'll be (working off Jerry's solution)
.wrapper{
border: solid 3px #4D545E; padding: 6px;
}
.center{
text-align:center;
}
strong {
color: #c01d21;
}
a {
text-transform: uppercase;
line-height: 38px;
text-algin: center;
}
I moved all your styling to CSS. And the html would be (same as above) + more <p> or any other tag you choose to add.
<div class="wrapper">
<p><strong>Book your Christmas party</strong> on any Monday-Thursday in November – and all your guests will receive a complimentary Sorbete al Cava cocktail.</p>
<p class="center">
<a class="link" href="http://www.manchesterconfidential.co.uk/b.aspx?b=6980" target="_blank"><strong>Click to book a table</strong></a></p>
<P class="center">Or call <strong>#### ### ####</strong></p>
<p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.</p>
<p class="center"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.</p>
<p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.</p>
</div>
Hope this helps.
p.one {
border-style: solid;
border-width: 5px;
}
<p class="one">Some text.</p>
http://www.w3schools.com/css/css_border.asp
Sorry guys, I'm really up against it here and I don't always get chance to jump back on and reply. There is an intern here at the moment who can answer some of my HTML questions, but thank you all for your input. No doubt I'll have more questions soon... :)
I'm using Zurb Foundation, working on an accordion. The Zurb accordion comes with a CSS triangle that acts as a toggler, but I want to use two font-awesome icons instead, depending on whether the li has an active class or not. Right now I'm getting a placeholder for the icon image.
Would prefer to do this with CSS only, if possible.
Here's my CSS:
ul.accordion > li > div.title:after { content:"\f067"; display: block; width: 0;
height: 0; position: absolute; right: 20px; top: 8px;}
ul.accordion > li.active .title:after { content:"\f068"; display: block; width: 0;
height: 0; }
Here's the HTML:
<ul class="accordion">
<li class="active">
<div class="title">
<h5>Accordion Panel 1</h5>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</li>
<li>
<div class="title">
<h5>Accordion Panel 1</h5>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</li>
</ul>
The CSS shown does not specify the font-family: FontAwesome;. Try adding that.
Looks like it's not a permission issue but in case others come along I am leaving the links.
For localhost changing permissions on the font itself could help: Icon font (#font-face) not rendering on localhost
Or possible cross domain issues with Firefox: http://www.red-team-design.com/firefox-doesnt-allow-cross-domain-fonts-by-default
I have the following jquery mobile code:
<div data-role="collapsible">
<h3>I like to read a lot but sometimes I simply can't bring myself to do it</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi iaculis interdum felis, et tempor nunc commodo sit amet. Ut fringilla.
</p></div>
I need the h3 tag to word wrap as opposed to truncating as jquery mobile does by default.
I've tried changing the above h3 tag to:
<h3 style="white-space:normal;">
or adding the following to the style sheet
h3 { white-space:normal; }
or
.h3 { white-space:normal; }
None of which works...any ideas? I could wrap it with line breaks but that's no good as it looks ugly if someone changes the orientation of their phone.
Thanks
Darren
You had the right idea. JQM just does some funky markup and you were targeting the wrong thing in the end.
.ui-collapsible h3 .ui-btn-text{white-space:normal;}