CSS - Added indentation is not working for nested ul li - html

I'm newbie to CSS, I want to add some extra spacing to the ul -lis which have parent ul.optiongroup. But those ul.optiongroup can also contain more ul.optiongroups and lis. So. Here is the html look like [Pl.see my old query for reference if required] and the JsFiddle:
NESTED UL-LIs:
<div id="target" class="treeselector">
<div class="styledSelect">
Select
</div>
<ul class="optiongroup expand" rel="Home">
<li class="title">
<span> </span>Home
</li>
</ul>
<ul class="optiongroup expand" rel="Products">
<li class="title">
<span class="fa fa-minus-square-o"> </span>Products
</li>
<li rel="PCPROducts1" class="expand">
PCPROducts1
</li>
<li rel="PCPROducts5" class="expand">
PCPROducts5
</li>
<ul class="optiongroup expand" rel="PCPROducts6">
<li class="title">
<span class="fa fa-plus-square-o"> </span>PCPROducts6
</li>
<ul class="optiongroup" rel="6th Product">
<li class="title">
<span class="fa fa-plus-square-o"> </span>6th Product
</li>
<li rel="Digital">
Digital
</li>
<li rel="Analog">
Analog
</li>
</ul>
</ul>
</ul>
</div>
Tried to add CSS like this:
.optiongroup li{
margin-left:40px;
border: 1px red solid; /* Just to see what's happening there */
}
How can I achieve this?
What's the easiest way to design ul -li with minimum css here.

You're using a lot of UL tags when its not needed.
You could try doing something like this:
<ul>
<li>Lorem</li>
<li>Aliquam</li>
<li>
<ul>
<li>Lorem ipsum .</li>
<li>Aliquam tincidunt</li>
<li>Vestibulum</li>
</ul>
</li>
<li>Lorem ipsum</li>
<li>Aliquam tincidunt</li>
</ul>
Notice that second UL is inside the LI

Related

How can I add a submenu to the sidenav in Materialize?

How can I add submenu to the following sidenav?
<ul class="sidenav sidenav-fixed" id="nav-mobile" style="width:250px">
<li> Text here</li>
<li>
<div class="divider"></div>
</li>
<li>
<a onclick="load('home')"><i class="material-icons">home</i>Home</a>
</li>
<li><a onclick="load('intro')"><i class="material-icons">apps</i>Content Table</a></li>
</ul>
MaterializeCSS documentation site uses a collapsible inside the sidenav:
https://materializecss.com/collapsible.html
Collapsible is a separate component that also needs initialising:
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.collapsible');
var instances = M.Collapsible.init(elems);
});
Working codepen:
https://codepen.io/doughballs/pen/RwPWVqy
The actual markup taken from the Materialize doc site is:
<!-- Start nested content -->
<li>
<ul class="collapsible collapsible-accordion">
<li>
<a class="collapsible-header waves-effect waves-teal" tabindex="0"><i class="material-icons">menu</i>Nested</a>
<div class="collapsible-body">
<ul>
<li>Color</li>
<li>Grid</li>
<li>Helpers</li>
<li>Media</li>
<li>Pulse</li>
<li>Sass</li>
<li>Shadow</li>
<li>Table</li>
<li>Transitions</li>
<li>Typography</li>
</ul>
</div>
</li>
</ul>
</li>
You can do something like below with MaterializeCSS
<div id="slide-out" class="sidenav" style="transform: translateX(0%);">
<ul class="collapsible">
<li class="active">
<div class="collapsible-header">
Group1
</div> <div class="collapsible-body" style="display: block;">
<li>Course 1</li>
<li>Course 2</li>
</div>
</li>
<li class="">
<div class="collapsible-header">
केंद्रीय लोकसेवा आयोग
</div>
<div class="collapsible-body" style="">
</div>
</li>
</ul>
</div>

use li element as a button

I have ul elements like below in my html
<ul class="nav" id="loadCategories">
<li class="sub-menu">Search by category
<ul class="">
<li>Food</li>
<li>Sports</li>
<li>Personal</li>
</ul>
</li>
<li class="sub-menu">Search by city
<ul class="">
<li>Mumbai</li>
<li>Bangalore</li>
<li>Personal</li>
</ul>
</li>
</ul>
Now I want to use a button just below this ul. But when I put something like the code below it breaks.
<input type="button" class="signout_btn" value="Sign Out" id="btnSignOut">Signout</input>
So is there any way I can put my button as a li element in order to get the exact same look(CSS).
Here's the fiddle for the same. The button should look like the ul element
Here is the code just add a button in a "li" element and remove bullet.
<ul class="nav" id="loadCategories">
<li class="sub-menu">
Search by category
<ul class="">
<li>Food</li>
<li>Sports</li>
<li>Personal</li>
</ul>
</li>
<li class="sub-menu">
Search by city
<ul class="">
<li>Mumbai</li>
<li>Bangalore</li>
<li>Personal</li>
</ul>
</li>
<li class="no-bullet">
<button type="button" class="signout_btn" id="btnSignOut">Sign Out</button>
</li>
</ul>
Also make the list-style-type to none
.no-bullet{
list-style-type: none
}
Here is a fiddle check it out.Hope it helps!! link
Did you try width=100% and height=100% with set parameters for the list?
you can try this
<ul class="nav" id="loadCategories">
<li><input type="button" class="signout_btn" value="Sign Out" id="btnSignOut">Signout</li>
<li class="sub-menu">Search by category
<ul class="">
<li>Food</li>
<li>Sports</li>
<li>Personal</li>
</ul>
</li>
<li class="sub-menu">Search by city
<ul class="">
<li>Mumbai</li>
<li>Bangalore</li>
<li>Personal</li>
</ul>
</li>
</ul>
<input> elements are empty (you shouldn't use end tags). I prefer to use <button> elements:
<button class="signout_btn" id="btnSignOut">Sign Out</button>
Could you please check with this code?
<ul class="nav" id="loadCategories">
<li class="sub-menu">Search by category
<ul class="">
<li>Food</li>
<li>Sports</li>
<li>Personal</li>
</ul>
</li>
<li class="sub-menu">Search by city
<ul class="">
<li>Mumbai</li>
<li>Bangalore</li>
<li>Personal</li>
</ul>
</li>
<li class="sub-menu">
<button class="signout_btn" id="btnSignOut" style="background: none;border:none;color: #fff;margin-left: 20px;">Sign Out</button>
</li>
</ul>
The output will be:
Please try below code snippet..
<ul class="nav" id="loadCategories">
<li class="sub-menu">Search by category
<ul class="">
<li>Food</li>
<li>Sports</li>
<li>Personal</li>
</ul>
</li>
<li class="sub-menu">Search by city
<ul class="">
<li>Mumbai</li>
<li>Bangalore</li>
<li>Personal</li>
</ul>
</li>
<input type="button" class="signout_btn" value="Sign Out" id="btnSignOut">
</ul>
CSS:
.signout_btn{
text-transform: uppercase;
outline: none;
border: 0;
background-color: #673a9a;
line-height: 40px;
color: #fff; display: inline-block;
font-size: 16px;
margin: 10px;
cursor: pointer;
}
JAVASCRIPT:
$( ".menu" ).click(function() {
$('.slide-menu').addClass('active');
$('.slide-wrapper').addClass('active');
});
$( "li.sub-menu" ).click(function() {
$(this).toggleClass('act');
$(this).find('ul').slideToggle();
});

BEM - How to manage multiple nested class names

I have the following,
<header id="header">
<div class="header__top">
<div class="container">
<ul class="top-nav"><!-- new name -->
<li class="dropdown top-nav__profile">
Hi Mallinda!
<ul class="dropdown-menu">
<li>Profile</li>
<li class="top-nav__saved">Saved Searches</li>
<li class="top-nav__saved">Saved Agents</li>
<li class="top-nav__saved">Saved Listings</li>
<li>Email Preferences</li>
<li>Logout</li>
</ul>
</li>
<li class="top-nav__icon">
<i class="zmdi zmdi-notifications"></i>
</li>
<li class="pull-right top-nav__icon">
<i class="zmdi zmdi-facebook"></i>
</li>
<li class="pull-right top-nav__icon">
<i class="zmdi zmdi-twitter"></i>
</li>
<li class="pull-right top-nav__icon">
<i class="zmdi zmdi-google"></i>
</li>
</ul>
</div>
</div>
</header>
Since I have a lot of nested classes, I've decided to choose a new name 'top-nav' after certain level. Is it valid in BEM? or do I need to phrase block name 'header__' to every child element?
You may put blocks inside other blocks or elements. It is absolutely valid.

Picture and bullet points next to eachother within columns as divs

I have been browsing and searching around for sometime now to find a working example of a picture in one column and text with bullet points in the other.
This is my result so far.
As you can see the text doesn't start at the top as I want it to.
<div style="overflow:hidden;position:relative;display:table">
<div style="display:table-cell;background:red">
<img src="http://www.lyricsmode.com/i/bpictures/4795.jpg" />
</div>
<div style="display:table-cell;width:100%;background:grey;">
<p>
Here is some text about how awesome Spongebob squarepants is!
</p>
<ul>
<li>Home
<ul>
<li>Dashboard</li>
</ul>
</li>
<li>Views
<ul>
<li>Tickets</li>
</ul>
</li>
<li>Customers
<ul>
<li>List of Customers</li>
</ul>
</li>
<li>Conditional
<ul>
<li>Admin extension</li>
</ul>
</li>
</ul>
</div>
Link to example in Fiddle
Try this
Fiddle Demo
<div style="overflow:hidden;position:relative;display:inline-flex">
just change the display css to inline-flex
try this.. I think this is what you're looking for.
<div style="float:left; background:red">
<img src="http://www.lyricsmode.com/i/bpictures/4795.jpg" />
</div>
<div style="background:grey; float:left;">
<p>
Here is some text about how awesome Spongebob squarepants is!
</p>
<ul>
<li>Home
<ul>
<li>Dashboard</li>
</ul>
</li>
<li>Views
<ul>
<li>Tickets</li>
</ul>
</li>
<li>Customers
<ul>
<li>List of Customers</li>
</ul>
</li>
<li>Conditional
<ul>
<li>Admin extension</li>
</ul>
</li>
</ul>
</div>
How about you actually use a table if you want the get that effect.
Try this html in the snippet:
<table >
<tr>
<td style="display:table-cell;background:red">
<img src="http://www.lyricsmode.com/i/bpictures/4795.jpg" />
</td>
<td style="display:table-cell;width:100%;background:grey;">
<p>
Here is some text about how awesome Spongebob squarepants is!
</p>
<ul>
<li>Home
<ul>
<li>Dashboard</li>
</ul>
</li>
<li>Views
<ul>
<li>Tickets</li>
</ul>
</li>
<li>Customers
<ul>
<li>List of Customers</li>
</ul>
</li>
<li>Conditional
<ul>
<li>Admin extension</li>
</ul>
</li>
</ul>
</td>
</tr>
</table>
You gonna have to change your divs into table and td respectively and add your td items (img and text containers) into tr.
If you have some constraints about this solution let me know.
ADVICE:
don't use inline styles, your markup gets really messy and it's difficult to make any changes later on.

Strange border line in IE8 that I didn't add

Same HTML, CSS, and image file, but in IE8 I have this weird border line.
HTML:
<div id="admin_link_div">
<ul id="vertical_menu">
<li>
<a href="/admin/appointment_list">
<div id="sidebar_left_box">
Room List
</div><img id="admin_arrow_img_roomlist" src="/images/arrow_off_icon.gif"></a>
</li><div id="sidebar_line"></div>
<li>
<a href="#">
<div id="sidebar_left_box">
User Management
</div><img id="admin_arrow_img_userlist" src="/images/arrow_off_icon.gif"></a>
<br>
<ul>
<li>
User List
</li>
<li>
User Register
</li>
</ul>
</li><div id="sidebar_line"></div>
<li>
<a href="#">
<div id="sidebar_left_box">
Company Mangement
</div><img id="admin_arrow_img_register" src="/images/arrow_off_icon.gif"></a>
<br>
<ul>
<li>
Company List
</li>
<li>
Company Register
</li>
</ul>
</li><div id="sidebar_line"></div>
<li>
<a href="#">
<div id="sidebar_left_box">
Service Management
</div><img id="admin_arrow_img_service" src="/images/arrow_off_icon.gif"></a>
<br>
<ul>
<li>
Server Management
</li>
<li>
Barbie Management
</li>
</ul>
</li>
</ul>
</div>
CSS:
#admin_arrow_img_userlist{
margin-left: 10px;
margin-bottom: 2px;
}
Any good reason???
add this to your image #
outline:none;
border: none;
because IE sets a border for images by default!!
Try this CSS on image
img
{
border:0;
outline:none;
}
Use border 0 Check link more appropriate.