Remove an inline width style setting with CSS [duplicate] - css

This question already has answers here:
How can I remove CSS element style inline (without JavaScript)?
(6 answers)
Closed 6 years ago.
I have a div that looks like this:
<div class="wtHolder" style="width:41.66%; height:150px; position:relative;">
Is there something I can add in css for the wtHolder class that will remove width:41.66% of this?
(If you want the background of why I need to do this, see this question.)

yes you can use !important to overwrite it:
.wtHolder {
width: 100px !important;
}

It's a trick , but you can actually use !important
.wtHolder{
width:100% !important;
background-color:black
}
<div class="wtHolder" style="width:41.66%; height:150px; position:relative;">

Related

Is it possible to combine CSS :host() with other pseudoelements? [duplicate]

This question already has answers here:
Can the CSS :part pseudo-selector be used to style nested web components?
(2 answers)
Closed 8 months ago.
I'm trying to define some style on the :before pseudo-element of a custom element host.
I've been trying variations around the sample below, but nothing seems to work and I can't find information about it. Is that possible at all? If so, what am I doing wrong?
:host(.open):before{
background: grey;
opacity:.4;
position: absolute;
left:0;
top:0;
width:100%;
height:100%;
}
Here's a fiddle to show the issue: https://jsfiddle.net/8uzjb7ew/ . The custom element should have greyish background, but the :before pseudoelement is not rendered.
I'm not sure about specific :host() pseudo element, but you can combine pseudo elements.
div:target{
background-color:orange;
}
div:before{
content:"*";
}
div:not(#D):target:before{
content:"Targeted, not DEF - ";
}
To ABD
To DEF
To GHI
<div id="A">ABC</div>
<div id="D">DEF</div>
<div id="G">GHI</div>

Hide #text in CSS [duplicate]

This question already has answers here:
Hide text in html which does not have any html tags [duplicate]
(3 answers)
Closed 2 years ago.
I'm trying to hide #text in CSS
Screenshot
Screenshot2
What kind of CSS should I write to hide this text?
Thank you in advance.
div{
height:100px;
width:100px;
margin:10px;
background:aqua;
}
.invis:hover{
visibility:hidden;
}
.display{
display:none;
}
<div class="invis"></div>
<div class="display"></div>
Depends, you have more options to hide something:
You have 1st:
visibility: hidden;
//or
opacity: 0;
2nd:
display: none;
Visibilty and opacity just make it invisble, but the box model is still acting in your html, so things have paddin margin and stuff.
Display none will actually dont display the element and will hide the element in the source code

nested div CSS selector [duplicate]

This question already has answers here:
Is there a CSS parent selector?
(33 answers)
Closed 7 years ago.
I have DOM like this
<div class="outer">
<div class="inner">
</div>
</div>
and corresponding CSS is like
.outer {
width: 700px;
}
, where inner could by typeA, typeB.....
Later I found that I want to enlarge outer when particular typeX show up, but
.outer .typeX {
width: 90%;
}
will apply style width: 90% to .typeX div not .outer div. How do I solve this? Is it possible in pure CSS? (Assume .outer is fixed since it is generated by other library)
Unfortunately, what you are looking for would be a parent selector, which does not yet exist in CSS.
Maybe someday (e.g., in Selectors Level 4).

How can I apply styling to parent element when child is in hovered? [duplicate]

This question already has answers here:
Is there a CSS parent selector?
(33 answers)
Closed 8 years ago.
Is this possible with css only? I have the following:
<div class="container">
<img src=#>
</div>
How do I get .container to have a box-shadow (and other styling) when and only when img is in the state :hover?
As people have stated there is no CSS parent selector, for a number of good reasons as stated in the linked duplicate question.
However, with the code you've shown, you can just apply the hover pseudo-selector to your parent element and it will achieve almost the exact same functionality.
So this:
div:hover{
border:1px solid red
}
Would work only because you have a single child, and would have the issue that if you hover adjacent to the img but not directly on it the parent will still have styles applied because its a block element.
You can convert it to inline-block to limit this, like so:
div{
display:inline-block;
}
div:hover{
border:1px solid red;
}
However, this will have implications for how other sibling elements to the parent flow.
You can use jQuery:
$("span").hover(
function () {
$(this).parent().addClass("add-class");
},
function () {
$(this).parent().removeClass("add-class");
}
);
Here is the demo http://jsfiddle.net/Sv6Av/
You can replace span with another tag such as img
Nope. No parent selector in css yet. You will have to resort to js for now. For more explanation read this

How to make text inside a div multiline? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
wrapping the text inside div - css
Fiddle: http://jsfiddle.net/aTFK2/2/
HTML:
<div id="ChannelDescription">ThisIsAVeryLongTextWithoutAnySpacesLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmed</div>​
CSS:
#ChannelDescription {
width:560px;
color:Gray;
white-space:normal;
font-size:14px;
}​
NOTE: I cannot change the width to any other value. Neither can I use break points. I am looking for a pure CSS2 solution.
word-wrap: break-word; will solve the problem.

Resources