CSS/SCSS select element not having successor with class - css

I have the following html:
<ul class="pagination ">
<li class="">
<a href="/en/products/page5">
<span><i class="fa fa-chevron-left"></i></span>
</a>
</li>
<li class="">
1
</li>
<li class="">
2
</li>
<li class="">
3
</li>
<li class="">
4
</li>
<li class="">
5
</li>
<li class="active">
6
</li>
<li class="hide">
<a href="/en/products/page7">
<span><i class="fa fa-chevron-right"></i></span>
</a>
</li>
</ul>
In this example, I'm on the last page, so the 'next page' button is automatically hidden.
I want the last visible item (page 6) to have rounded borders.
How can I select 'page 6' with css/scss without changing the HTML?
I thought about something like this:
.pagination > li:not( + li.hide) > a,
.pagination > li:not( + li.hide) > span {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
But this doesn't work.
Just to be clear: I want to select the item before the .hide without depending on the .active class.

You can use the :nth-last-child() selector to start from the end of the list of items and select the second to last item you have. Here is how nth-last-child works.
.pagination > li {
border: 2px solid #000;
display: inline-block;
padding: 5px 10px;
margin: 5px;
}
.pagination > li.active:nth-last-child(2) {
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
}
.pagination > li.hide {
display: none;
}
<ul class="pagination ">
<li class="">
<a href="/en/products/page5">
<span><i class="fa fa-chevron-left"></i></span>
</a>
</li>
<li class="">
1
</li>
<li class="">
2
</li>
<li class="">
3
</li>
<li class="">
4
</li>
<li class="">
5
</li>
<li class="active">
6
</li>
<li class="hide">
<a href="/en/products/page7">
<span><i class="fa fa-chevron-right"></i></span>
</a>
</li>
</ul>

I don't think you can achieve this with css alone.
I know you haven't tagged your question with javascript or jquery, but here is a solution using CSS and jQuery that may help.
I've used color property instead of border for simplicity.
$('.hide').prev("li").find("a").addClass('border');
.border {
color: red;
}
.pagination > li:last-child:not(.hide) > a {
color: red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="pagination ">
<li class="">
<a href="/en/products/page5">
<span><i class="fa fa-chevron-left"></i></span>
</a>
</li>
<li class="">
1
</li>
<li class="">
2
</li>
<li class="">
3
</li>
<li class="">
4
</li>
<li class="">
5
</li>
<li class="active">
6
</li>
<li class="hide">
<a href="/en/products/page7">
<span><i class="fa fa-chevron-right"></i>arrow</span>
</a>
</li>
</ul>
<ul class="pagination ">
<li class="">
<a href="/en/products/page5">
<span><i class="fa fa-chevron-left"></i></span>
</a>
</li>
<li class="">
1
</li>
<li class="">
2
</li>
<li class="">
3
</li>
<li class="">
4
</li>
<li class="">
5
</li>
<li class="active">
6
</li>
</ul>

Related

CSS :not() is not working as I would expect

I've got the following HTML and CSS code which can also be found and played with here //jsfiddle.net/0k1qah6x/7/
My intent is for the number "1" which has the class "active" not to be red.
.pdf-pagination a:not(.active) {
color: red;
text-decoration: none;
}
<div class="pdf-pagination">
<ul>
<li class="disabled">
<a id="pdfPaginationLink0" href="#" data-page="0">←</a>
</li>
<li class="active">
<a id="pdfPaginationLink1" href="#" data-page="1">1</a>
</li>
<li>
<a id="pdfPaginationLink2" href="#" data-page="2">2</a>
</li>
<li>
<a id="pdfPaginationLink3" href="#" data-page="2">→</a>
</li>
</ul>
</div>
Your anchors don't have the .active class, their parent li do.
You'll have to change your selector and move the :not() deselector to the parent, as follows:
.pdf-pagination li:not(.active) a {
color: red;
text-decoration: none;
}
<div class="pdf-pagination">
<ul>
<li class="disabled">
<a id="pdfPaginationLink0" href="#" data-page="0">←</a>
</li>
<li class="active">
<a id="pdfPaginationLink1" href="#" data-page="1">1</a>
</li>
<li>
<a id="pdfPaginationLink2" href="#" data-page="2">2</a>
</li>
<li>
<a id="pdfPaginationLink3" href="#" data-page="2">→</a>
</li>
</ul>
</div>

Twitter Boostrap - Align label horizontally to dropdown

I would like to have the label for the dropdown next to the dropdown menus.
Find below how my current example looks like:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<ul class="nav nav-pills" role="tablist">
<li role="presentation">Order: </li>
<li role="presentation" class="dropdown">
Ticker<span class="caret"></span>
<ul class="dropdown-menu" id="menu1" aria-labelledby="drop4">
<li>
Action
</li>
<li>
Another action
</li>
<li>
Something else here
</li>
<li role="separator" class="divider"></li>
<li>
Separated link
</li>
</ul>
</li>
</ul>
Any suggestions how to align the label with the dropdown properly?
Thx in advance!
I'm not sure I understand correctly, but for alignment I would use a flexbox.
.nav-pills {
display: flex;
align-items: center;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<ul class="nav nav-pills" role="tablist">
<li role="presentation">Order: </li>
<li role="presentation" class="dropdown">
<a href="#" class="dropdown-toggle" id="drop4" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Ticker
<span class="caret"></span>
</a>
<ul class="dropdown-menu" id="menu1" aria-labelledby="drop4">
<li>
Action
</li>
<li>
Another action
</li>
<li>
Something else here
</li>
<li role="separator" class="divider"></li>
<li>
Separated link
</li>
</ul>
</li>
Just add the below css in your custom css file
.nav-pills>li:not(.dropdown) {
padding: 10px 12px;
}
.nav-pills>li:not(.dropdown) {
padding: 10px 12px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<ul class="nav nav-pills" role="tablist">
<li role="presentation">Order: </li>
<li role="presentation" class="dropdown">
Ticker<span class="caret"></span>
<ul class="dropdown-menu" id="menu1" aria-labelledby="drop4">
<li>
Action
</li>
<li>
Another action
</li>
<li>
Something else here
</li>
<li role="separator" class="divider"></li>
<li>
Separated link
</li>
</ul>
</li>
</ul>
You can simply add padding like this :
/* Optional theme */
#import url('//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
ul.nav > li:first-child {
padding:10px 5px;
}
<ul class="nav nav-pills" role="tablist">
<li role="presentation" >Order: </li>
<li role="presentation" class="dropdown">
<a href="#" class="dropdown-toggle" id="drop4" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Ticker
<span class="caret"></span>
</a>
<ul class="dropdown-menu" id="menu1" aria-labelledby="drop4">
<li>
Action
</li>
<li>
Another action
</li>
<li>
Something else here
</li>
<li role="separator" class="divider"></li>
<li>
Separated link
</li>
</ul>
</li>
Use Flex to nav pills
.nav-pills{
display:flex;
align-items:center;
}
JS FIDDLE: https://jsfiddle.net/pradeep0594/qfwngj5x/1/ for your reference
I like Gerard's display: flex solution better, but just in case anyone prefers to maintain the original display property, here is an example using only line-height to vertically center both .nav-pills.
<style>
.nav-pills > li {
line-height: 40px;
}
.nav.nav-pills > li > a {
/* removes top & bottom padding */
padding: 0 15px;
}
</style>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<ul class="nav nav-pills" role="tablist">
<li role="presentation">Order: </li>
<li role="presentation" class="dropdown">
Ticker<span class="caret"></span>
<ul class="dropdown-menu" id="menu1" aria-labelledby="drop4">
<li>
Action
</li>
<li>
Another action
</li>
<li>
Something else here
</li>
<li role="separator" class="divider"></li>
<li>
Separated link
</li>
</ul>
</li>
</ul>

navbar styling issues with Material framework

I am not able to keep my all ul/li list with logo and logged user name on the nav bar using materializecss? There are 6 navigations with a logo with a user name that I want to keep on the nav bar but, i am not able to keep all these on the nav bar. logo comes on the navigations text and user name come below of the nav bar. below are the some part of the html code.
<div class="navbar-fixed">
<nav>
<div class="nav-wrapper white black-text">
<img style="height: 56px;width: 70px;" src="<?php echo base_url(); ?>assets/images/Pratham-1.png">
<i class="material-icons menu">menu</i>
<ul class="right hide-on-med-and-down">
<!-- <li> <?php echo $name;?></li>
<li>Logout</li> -->
<li><a class="dropdown-button" href="#!" data-activates="basicinfo"><i class="material-icons left">language</i>Basic Information<i class="material-icons right">arrow_drop_down</i></a></li>
<li><a class="dropdown-button" href="#!" data-activates="learningresults"><i class="material-icons left">show_chart</i>Learning Results<i class="material-icons right">arrow_drop_down</i></a></li>
<li><a class="dropdown-button" href="#!" data-activates="attendance"><i class="material-icons left">supervisor_account</i>Attendance<i class="material-icons right">arrow_drop_down</i></a></li>
<li><a class="dropdown-button" href="#!" data-activates="monitoringinformation"><i class="material-icons left">search</i>Monitoring Information<i class="material-icons right">arrow_drop_down</i></a></li>
<li><a class="dropdown-button" href="#!" data-activates="others"><i class="material-icons left">speaker_notes</i>Others<i class="material-icons right">arrow_drop_down</i></a></li>
<li><i class="material-icons left">vertical_align_bottom</i>Download Data</li>
<li><a class="dropdown-button" href="#!" data-activates="dropdown1"><?php echo $name;?><i class="material-icons right">arrow_drop_down</i></a></li>
</ul>
<!-- Dropdown for Baisc Info large screen-->
<ul id="basicinfo" class="dropdown-content">
<li>Reach 2016-17</li>
<li class="divider"></li>
<li>What is Read? India</li>
<li>Tools & MME Formats</li>
<li>Implementation models</li>
<li>Archives</li>
</ul>
<!-- Dropdown for Learnign Levels large screen-->
<ul id="learningresults" class="dropdown-content">
<li>Camp-wise Results</li>
<li>Jumps Across Reading Levels</li>
<li>Know Your Progress</li>
<li>Comparison Reports</li>
<li>Goal Tracker</li>
</ul>
CSS - i have tried this so far I have tried this so far -
nav {
height: 120px;
line-height: 90px;
font-size: 12px;
}
nav i, nav [class^="mdi-"], nav [class*="mdi-"], nav i.material-icons {
/*height: 30px;
line-height: 30px;*/
}
nav .button-collapse i {
/* height: 30px;
line-height: 30px;*/
}
nav .brand-logo {
font-size: 1.6rem;
}
#media only screen and (min-width: 601px){
nav, nav .nav-wrapper i, nav a.button-collapse, nav a.button-collapse i {
/* height: 30px;
line-height: 30px;*/
}
}
nav a:hover {
color: blue;
/* text-decoration: underline;*/
}
I think this is more an issue with UI/UX design. I think this would look best on desktop as a side-nav that's fixed.
Here's an example from the Materialize Documentation without the need of changing the CSS:
<ul id="nav-mobile" class="side-nav fixed">
<li class="logo"><a id="logo-container" href="http://materializecss.com/" class="brand-logo">
<object id="front-page-logo" type="image/svg+xml" data="res/materialize.svg">Your browser does not support SVG</object></a></li>
<li class="search">
<div class="search-wrapper card">
<input id="search"><i class="material-icons">search</i>
<div class="search-results"></div>
</div>
</li>
<li class="bold">About</li>
<li class="bold">Getting Started</li>
<li class="no-padding">
<ul class="collapsible collapsible-accordion">
<li class="bold"><a class="collapsible-header waves-effect waves-teal">CSS</a>
<div class="collapsible-body">
<ul>
<li>Color</li>
<li>Grid</li>
<li>Helpers</li>
<li>Media</li>
<li>Sass</li>
<li>Shadow</li>
<li>Table</li>
<li>Typography</li>
</ul>
</div>
</li>
<li class="bold"><a class="collapsible-header active waves-effect waves-teal">Components</a>
<div class="collapsible-body">
<ul>
<li>Badges</li>
<li>Buttons</li>
<li>Breadcrumbs</li>
<li>Cards</li>
<li>Chips</li>
<li>Collections</li>
<li>Footer</li>
<li>Forms</li>
<li>Icons</li>
<li class="active">Navbar</li>
<li>Pagination</li>
<li>Preloader</li>
</ul>
</div>
</li>
<li class="bold"><a class="collapsible-header waves-effect waves-teal">JavaScript</a>
<div class="collapsible-body">
<ul>
<li>Carousel</li>
<li>Collapsible</li>
<li>Dialogs</li>
<li>Dropdown</li>
<li>Media</li>
<li>Modals</li>
<li>Parallax</li>
<li>Pushpin</li>
<li>ScrollFire</li>
<li>Scrollspy</li>
<li>SideNav</li>
<li>Tabs</li>
<li>Transitions</li>
<li>Waves</li>
</ul>
</div>
</li>
</ul>

6 column fluid layout

I'm trying to achieve a 6 column fluid layout, like so:
<ul class="list">
<li class="list-element first">
<a>Item 1</a>
</li>
<li class="list-element">
<a>Item 2</a>
</li>
<li class="list-element">
<a>Item 3</a>
</li>
<li class="list-element">
<a>Item 4</a>
</li>
<li class="list-element">
<a>Item 5</a>
</li>
<li class="list-element last">
<a>Item 6</a>
</li>
</ul>
My list should be 100% width and every list element LINK (ul li a) should fit equally into it. Did some research and didn't find any 6 column fluid layout to match my request (or I'm just too tired to see it).
Any oppinion?
TIA
Use the css float on the li and a width of 16.66666666666667% this means 100/6.
here is a sample css. and a fiddle
.list {
list-style: none;
margin: 0;
padding: 0;
}
.list li {
width: 16.66666666666667%;
float: left;
}
.list li a {
display: block;
border: 1px solid #ddd;
text-align: center;
}
<ul class="list">
<li class="list-element first">
<a>Item 1</a>
</li>
<li class="list-element">
<a>Item 2</a>
</li>
<li class="list-element">
<a>Item 3</a>
</li>
<li class="list-element">
<a>Item 4</a>
</li>
<li class="list-element">
<a>Item 5</a>
</li>
<li class="list-element last">
<a>Item 6</a>
</li>
</ul>

Selecting CSS3 Last Child Within Drop Down Menu Not Working

Frustratingly not been able to resolve the CSS3 pseudo element 'last-child' that isn't working with this custom drop down navigation menu that we're working on currently.
Each drop down menu can be assigned a number of columns, in this instance, I am wanting to apply a right hand border to each column (.col_1) within the div .dropdown_3column.
CSS Snippet
.dropdown_1column_simple {width: 100px;}
.dropdown_2column_simple {width: 155px;}
.dropdown_1column {width: 550px;}
.dropdown_2column {width: 650px;}
.dropdown_3column {width: 500px;}
.dropdown_4column {width: 800px;}
.dropdown_5column {width: 1000px;}
.dropdown_2column_simple .col_1 {width:155px;}
.dropdown_2column_simple .col_2 {width:155px;}
.col_1 {width:145px; border-right: 1px solid #888;}
.col_2 {width:240px;}
.col_3 {width:490px;}
.col_4 {width:440px;}
.col_5 {width:575px;}
.col_s {width:250px;}
.col_1,.col_2,.col_3,.col_4,.col_5 {
display:inline;
float: left;
position: relative;
margin-left: 5px;
margin-right: 5px;
/*border: 1px solid #000;*/
}
HTML Snippet
<div class="dropdown_3column align_left ">
<div class="col_3">
<div class="content_top"></div>
</div>
<div class="col_1">
<ul>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/addict-clothing.html">
<span class="level1">Addict Clothing </span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/atticus-clothing.html">
<span class="level1">Atticus Clothing</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/dephect-clothing.html">
<span class="level1">Dephect Clothing</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/dickies-clothing.html">
<span class="level1">Dickies</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/dta-clothing.html">
<span class="level1">DTA Clothing</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/famous-stars-and-straps-clothing.html">
<span class="level1">Famous Stars And Straps Clothing</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/fuct-clothing.html">
<span class="level1">FUCT Clothing</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/hex-accessories.html">
<span class="level1">HEX Accessories</span>
</a>
</li>
</ul>
</div>
<div class="col_1">
<ul>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/the-hundreds.html">
<span class="level1">The Hundreds</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/insight-clothing.html">
<span class="level1">Insight Clothing</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/jeepney-clothing.html">
<span class="level1">Jeepney Clothing</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/king-apparel.html">
<span class="level1">King Apparel</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/lrg-clothing.html">
<span class="level1">LRG Clothing</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/my-yard-clothing.html">
<span class="level1">My Yard</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/new-era-5950.html">
<span class="level1">New Era 5950 Hats and Apparel</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/pxl-clothing.html">
<span class="level1">PXL Clothing</span>
</a>
</li>
</ul>
</div>
<div class="col_1">
<ul>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/rebel8-clothing.html">
<span class="level1">REBEL8 Clothing</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/ringspun-clothing.html">
<span class="level1">Ringspun</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/rogue-status-clothing.html">
<span class="level1">Rogue Status </span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/the-wild-ones-clothing.html">
<span class="level1">The Wild Ones</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/volcom-clothing.html">
<span class="level1">Volcom Clothing</span>
</a>
</li>
<li class="level1">
<a href="http://009rep.clubnetdev.com/brands/zoo-york-clothing.html">
<span class="level1">Zoo York Clothing</span>
</a>
</li>
</ul>
</div>
<div class="col_3">
<div class="content_bottom"></div>
</div>
<div class="col_s">
<div class="content_side"></div>
</div>
</div>
A live version of the problem can be seen here. It is the 'Brands' dropdown in question that I am trying to remove the right hand border from the 3rd (last) column.
I'm aware of browser incompatibilities and other alternatives using JS / jQuery that exist perhaps but I'm only interested in trying to resolve this with the CSS.
I'm thinking perhaps this needs a fresh pair of eyes because I've tried tons of variations and not managed to select the last column within that drop down I believe.
Thanks in advance.
EDIT: I have attempted tons of variations but I think the issue is my inability to work out the last child of the parent item which doesn't count other divs too. I've been trying with the likes of:
div:last-child .col_1 {border-right: none !important;}
Thanks.
EDIT 2: Please find instance of my issue on JS Fiddle too if it helps anyone.
Thanks.
You are not using selectors right.
Here is a fix using nth-child:
http://jsfiddle.net/BUhgZ/3/

Resources