I have below html code with List items. Here I don't want 'Minutes' list item so I want to hide it. How can I hide this item using CSS. I mean override this style in external css file
<div class="y-dropdown larger open">
<div class="placeholder">Daily</div>
<ul class="items" style="display: block;">
<li>Daily</li>
<li>Weekly</li>
<li>Monthly</li>
<li>Quarterly</li>
<li>Yearly</li>
<li>Minutes</li>
</ul>
</div>
Add CSS display:none for minutes like
li.minutes{
display:none;
}
If you have to overwrite some CSS properties you have to give !important to that property.
Here,
ul.items li.minutes {
diaplay: none!important;
}
I'm using a plugin that displays an autocomplete list in a form "dynamically."
I'd like to style the list but can't figure out which element it is or how to target it.
<div class="awesomplete">
<input id="omnibar" class="idx-omnibar-input" type="text" placeholder="City" autocomplete="off" aria-autocomplete="list">
<ul hidden=""></ul>
</div>
You can use ul[hidden] to select the ul elements with that attribute.
ul[hidden] {
display: none
}
<ul>
<li>Visible</li>
</ul>
<ul hidden>
<li>Hidden</li>
</ul>
you can use "display" from css and change for display:none or display:block (hidden & visible)
display:none (hidden)
display:block (visible)
Thank you for the responses. I was able to solve this by simply selected the div above it and adding li and using !important.
In this case all I wanted to do was style the words in the autocomplete section.
For reference my page was
<div id="shortcode_container">
<div class="awesomplete">
<input id="omnibar" class="idx-omnibar-input" type="text" placeholder="City" autocomplete="off" aria-autocomplete="list">
<ul hidden=""></ul>
</div>
#shortcode_container {
color: #ffffff !important;
}
I have a html code:
<div class="projLeader">
<div class="ui-widget-content">
<label>Captain:</label>
<ol>
<li class="placeholder" name="projLeader"><div class="adding">Drop Here</div></li>
<li class="dropClass" name="projLeader" <?php if (isset($projLeader)) echo 'value="'.$projLeader.'"' ?>><?php echo "<span class='closer'>x</span>".$projLeader.""?></li>
<input type="hidden" name="projLeader" class="hiddenListInput1" />
</ol>
</div>
</div>
I want to add css style:
.projLeader label
{
margin-left:25% !important;
}
But it does not work. if i put it inside label in html code it works:
<label style:'margin-left:25%;'>Captain:</label>
I have style for .projLeader:
.projLeader
{
float:left;
margin:3px;
width:30%;
}
And it works, so why it does not work with label?
As far as it looks this will probably work
.projLeader label
{
margin-left: 25% !important;
}
but consider this if .ui-widget-content has it's own selector for label in its CSS then your style will be denied. To give your style priority add the exact same selector .ui-widget-content Try to use inspect element to see what it used as a selector used and put your override CSS below that library.
.projLeader .ui-widget-content label
{
margin-left: 25% !important;
}
Hope that helps
~ is for the following sibling selector.
How could il select the class .content in reference to the class .select ?
HTML
<ul>
<li> <a>content</a> </li>
<li> <a class="select">selected li</a> </li>
<li> <a>content</a> </li>
</ul>
<div class="content">
selected content
<div>
CSS (not working)
ul > li > a.select ~ .content {
/* something */
}
It's unfortunately not possible with CSS, but you could use JQuery, i.e. something like
<script type="text/javascript">
$(".selected").parent().parent().siblings(".content").css("color", "red");
</script>
$(".selected") you start at 'a' tag
.parent() move to parent 'li'
.parent() move to parent 'ul'
.siblings(".content") matches all siblings of the 'ul' you are currently at with class #content'
.css("color", "red") do whatever fancy css you like ;)
There's currently no way in CSS to select the class .content in reference to the class .select.
However if you change your markup a little you can do something similar to what you're trying to do using the target pseudo-class
FIDDLE
For my <ul> list, I would like to add a <hr> after each element of a list. The Result should render like:
<ul class="mylist">
<li>
moooo!
<hr width="40%">
</li>
<li>
maaaaa!
<hr width="40%">
</li>
...
</ul>
It is bad style adding <hr> to each <li> so I would like to refractor this using css only. I cannot use:
.mylist > li: after{
content: "<hr>"
}
as content would escape the characters.
I also do not want to use jQuery:
$('.mylist').find('li').append('<hr width="40%">');
So the question is, how could I append <hr width="40%"> to each <li> of a certain list using css3 ?
jQuery Solution
Just realized that you wanted to nest the hr element inside the li before you close it, yes it's perfectly valid, so simply use append(), and note, you cannot do this using CSS only, as you cannot modify DOM using CSS, you need to use jQuery or JS
jQuery("ul li").append("<hr />");
Demo
CSS Solution
If you don't need an extra element, or you don't want a jQuery solution(As you want)
Using hr element as a direct child to ul element is not a valid markup, instead, you can use a border-bottom for each li which will behave same as hr does, still if you want an explicit way to do so, say for controlling the width of the separator without changing the width of li than you can do it like this
Demo
ul li:after {
content: "";
display: block;
height: 1px;
width: 40%;
margin: 10px;
background: #f00;
}
Here, am just creating a virtual block level element, which doesn't actually exists in the DOM, but it will just do the thing which you need. You can just design the element, the same way you style a normal div. You can also use border on this but to keep the thin line horizontally centered, I've assigned height: 1px; and than am using margin to space up.
I think it's better to use CSS for this. for example you can stop using <hr> tag, instead do something like:
<ul class="mylist">
<li>
moooo!
</li>
<li>
maaaaa!
</li>
...
</ul>
and then with CSS:
.mylist li { border-bottom: 1px solid black; }
There are other options too, for example if you want to show the horizontal line only for some list items, you can give them a class and add a CSS rule only for that class. like this:
<ul class="mylist">
<li class="hr">
moooo!
</li>
<li>
maaaaa!
</li>
...
</ul>
and CSS:
.mylist li.hr { border-bottom: 1px solid black; }
You can use like this:
<ul>
<li></li>
</ul>
<hr/>
Thats simple. If you have nested ul and li then you use li instead of <hr/> or simply <hr/> inside a <li></li> tag. See below. Its purely your choice.
<ul>
<li>
<ul><li></li></ul>
</li>
<li style="height:1px;border:solid 1px #666"> </li> // or you can also use
<li><hr/></li>
<li>
<ul>
<li></li>
</ul>
</li>
</ul>
Tags in content are not allowed and even if it would be very misleading (css { content: "text"}, How do i add tags?)
If you think is wrong to add <hr> in HTML than it is wrong adding with css (if it would be possible) or js. IMHO a first You should try to use border of <li> if result won't be as expected add that <hr>
Insert A Class That Creates A bottom-border: For Each <li>
<!--########## STYLE EACH li USING CLASS ##########-->
<style>
.hr {
width:40%;
border-bottom:1px solid rgba(0,0,0,.7);
}
</style>
<!--########### PAGE CONTENT ############-->
<ul class="mylist">
<li class="hr">
-CONTENT-
</li>
<li class="hr">
-CONTENT-
</li>
...
Try this CSS:
li:after {
content: " ";
display: block;
height: 2px;
width: 100%;
}