I've been trying to use
<ul style="text-align:center">
<li> 1794 - born in Berkeley, UK </li>
<li> 1821 - began his training as a doctor </li>
</ul>
Unfortunately, neither bullets and text align correctly, I've tried using divs and it still doesn't work.
This is what is happening:
This is what I want:
Try this simple code snippet
ul {
display: table;
margin: 0 auto;
}
<ul class="list">
<li class="list-item">1794 - born in Berkeley, UK</li>
<li class="list-item">1821 - began his training as a doctor</li>
</ul>
If you want to keep the list centered in the page/parent element, but have the list items aligned to the left, wrap the ul tag in a block container that has a text-align: center;, and set the ul as a display: inline-block; and text-align: left;.
Did you want this? https://codepen.io/anon/pen/WdyVPJ
Code
HTML
<ul class="list">
<li class="list-item">1794 - born in Berkeley, UK</li>
<li class="list-item">1821 - began his training as a doctor</li>
</ul>
CSS
ul {
text-align: left;
}
li {
text-align: center;
}
That's because you have to center the internal elements (<li>) while aligning to the left the external element (<ul>)
<ul style="text-align:left">
<li style="text-align:center"> 1794 - born in Berkeley, UK </li>
<li style="text-align:center"> 1821 - began his training as a doctor </li>
</ul>
Check the result here: https://jsfiddle.net/L1xmkof6/
Related
You can see that the icon and "sign in" link isn't straight. How do I fix this?
Here is the code:
https://html-css-js.com/?html=%3C!DOCTYPE%20html%3E%0A%3Chtml%20lang=%22en%22%3E%0A%20%20%3Chead%3E%0A%20%20%20%20%3Cmeta%20charset=%22UTF-8%22%20/%3E%0A%20%20%20%20%3Cmeta%20http-equiv=%22X-UA-Compatible%22%20content=%22IE=edge%22%20/%3E%0A%20%20%20%20%3Cmeta%20name=%22viewport%22%20content=%22wi$*$dth=device-wi$*$dth,%20initial-scale=1.0%22%20/%3E%0A%20%20%20%20%3Clink%20rel=%22stylesheet%22%20href=%22styles.css%22%20/%3E%0A%20%20%20%20%3Clink%20rel=%22stylesheet%22%20href=%22https://fonts.googleapis.com/icon?family=Material+Icons%22%3E%0A%20%20%20%20%3Ctitle%3EGoogle%3C/title%3E%0A%20%20%3C/head%3E%0A%20%20%3Cbody%3E%0A%20%20%20%20%3C/ul%3E%0A%20%20%20%20%20%20%3Cli%20class=%22right%20button%22%3E%3Ca%20href=%22#%22%3ESign%20In%3C/a%3E%3C/li%3E%0A%20%20%20%20%20%20%3Cli%20class=%22right%22%3E%3Cspan%20class=%22material-icons%20navigation%20icon%22%20%3Eapps%3C/span%3E%3C/li%3E%0A%20%20%20%20%20%20%3Cli%20class=%22right%22%3E%3Ca%20href=%22#%22%3EImages%3C/a%3E%3C/li%3E%0A%20%20%20%20%20%20%3Cli%20class=%22right%22%3E%3Ca%20href=%22#%22%3EGmail%3C/a%3E%3C/li%3E%0A%20%20%20%20%20%20%3Cli%20class=%22left%22%3E%3Ca%20href=%22#%22%3EAbout%3C/a%3E%3C/li%3E%0A%20%20%20%20%20%20%3Cli%20class=%22left%22%3E%3Ca%20href=%22#%22%3EStore%3C/a%3E%3C/li%3E%0A%20%20%20%20%3C/ul%3E%0A%0A%20%20%3C/body%3E%0A%3C/html%3E%0A&css=*%20%7B%0A%20%20margin:%200;%0A%20%20padding:%200;%0A%20%20font-size:%2012px;%0A%20%20font-family:%20arial,%20sans-serif;%0A%7D%0A%0Ali%20%7B%0A%20%20float:%20right;%0A%20%20list-style-type:%20none;%0A%20%20margin-top:%2020px;%0A%7D%0A%0Aa%20%7B%0A%20%20text-decoration:%20none;%0A%20%20color:%20black;%0A%7D%0A%0A.left%20%7B%0A%20%20float:%20left;%0A%7D%0A%0A.left%20a%20%7B%0A%20%20margin-left:%2020px;%0A%7D%0A%0A.right%20%7B%0A%20%20margin-right:%2020px;%0A%7D%0A%0A.button%20%7B%0A%20%20background-color:%20#4485f4;%0A%20%20padding:%207px;%0A%20%20border-radius:%205%25;%0A%7D%0A%0A.button%20a%20%7B%0A%20%20color:%20#fff;%0A%7D%0A%0A.icon%20%7B%0A%20%20color:%20grey;%0A%7D%0A%0Aa%20%7B%0A%20%20justify-items:%20center;%0A%7D%0A&js=
In your css, you can write this in your ul selector:
ul {
display: flex;
align-items: center;
}
But in this case, rearrange your html code and write them in the order the options are going to be on your navbar.
<ul>
<li class="left">About</li>
<li class="left">Store</li>
<li class="right">Images</li>
<li class="right">Gmail</li>
<li class="right"><span class="material-icons navigation icon">apps</span</li>
<li class="right button">Sign In</li>
</ul>
Another way is to do that is to use line-height in ul.
ul {
line-height: 20px;
}
Although it is not always perfect.
The HTML and CSS code is as follows;
I am using li ul as selectors to make my subjects hidden but it's not working
and I don't know why. Can some one please help (I am new to programming)
<div id="subjects">
<h3> SUBJECTS </h3>
<ul class="subjects">
<li> Introduction To Biochemistry </li>
<ul>
<li><a> new</a> </li>
<li><a> new</a> </li>
<li><a> new </a></li>
</ul>
<li> Chemistry Of Biomolecules </li>
<ul>
<li><a> new</a> </li>
<li><a> new</a> </li>
<li><a> new </a></li>
</ul>
</ul>
</div>
li ul {
visibility: hidden;
position: absolute;
width: 150px;
}
li:hover ul {
visibility: visible;
}
I think that is what you want
Edit
Also you have error in your HTTML. Your HTML should be like bellow. (Modifying your HTML according your CSS. But this not means that you must write HTML in this way)
<div id="subjects">
<h3> SUBJECTS </h3>
<ul class="subjects">
<li> Introduction To Biochemistry
<ul>
<li><a>new</a> </li>
<li><a>new</a> </li>
<li><a>new</a></li>
</ul>
</li>
<li> Chemistry Of Biomolecules
<ul>
<li><a>new</a> </li>
<li><a>new</a> </li>
<li><a>new</a></li>
</ul>
</li>
</ul>
</div>
CSS
li ul{
display:none;
position:absolute;
width:150px;
}
li:hover ul{
display: block;
}
You're selecting al ul tags in li tags, but your HTML is the other way around.
If you change your CSS to ul li { css_here } it should work.
Also when position: absolute; is set to the li items, the ul item doesn't wrap the items anymore, because they are removed from the document layout flow. So you might want to remove the position: absolute;.
I have a solution for my problem, but it doesn't seem right. I want to know what's going on.
Nested list item's background colour doesn't extend to the bottom even though there's no margin on it (see the gap below the blue background in the screen shots). The paragraph inside does have a margin. But I've tried to reproduce this outside of my app (which uses Bootstrap) and I can't. In Firebug I tried turning off all CSS except that which was necessary to show the problem (i.e., the background-color and border -- see 2nd image), but it makes no difference. Seen in Chrome and Firefox.
The fix is either adding bottom padding or overflow-y:auto; to the inner list item. But why? Has anyone encountered something like this?
I can't post all the code here, but the HTML at least is something like this:
<ul class="nav navbar-nav navbar-right">
<li class="dropdown open">
<ul class="dropdown-menu notification-list">
<li class="notification-new">
<div class="text-muted">01/13/2015</div>
<p>Check out the new features coming to the 2015.1 release here!</p>
</li>
<li class="notification-new">
<div class="text-muted">12/24/2014<button class="close" type="button"><span class="sr-only">Close</span></button></div>
<p>Upcoming server maintenance scheduled for 11:00pm PST.</p>
</li>
[Update] Here is a simplified, non-Bootstrap version. Why no gaps in this one?
ul {
width: 300px;
border: 1px solid red;
float: left;
}
li.sub {
border: 1px solid green;
background-color: yellow;
padding: 8px 8px 0;
}
p { margin:10px; /* no gaps with or without this */ }
<ul>
<li><p>item 1</p>
<ul>
<li class="sub">
<div>
something
</div>
<p>
stuff
</p>
</li>
<li class="sub">
<div>
something
</div>
<p>
stuff
</p>
</li>
</ul>
</li>
<li>thing
<ul>
<li class="sub">
nuther
</li>
</ul>
</li>
</ul>
The spacing is occurring because of the margins in the p elements inside the lis, specifically the bottom margin.
This behavior is defined as 'collapsing margins'. More info here: http://www.w3.org/TR/CSS2/box.html#collapsing-margins
You can see this by setting them to 0.
.notification-new p{
margin:0;
}
Live example: http://www.bootply.com/wlfIl3RziC
Full code below:
.notification-new {
background-color:red;
}
.notification-new p{
margin:0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown open">
<ul class="dropdown-menu notification-list">
<li class="notification-new">
<div class="text-muted">01/13/2015</div>
<p>Check out the new features coming to the 2015.1 release here!</p>
</li>
<li class="notification-new">
<div class="text-muted">12/24/2014<button class="close" type="button"><span class="sr-only">Close</span></button></div>
<p>Upcoming server maintenance scheduled for 11:00pm PST.</p>
</li>
</ul>
</li>
</ul>
I have this page where all the div's seem to work and then all of the sudden my last one breaks. I have two divs in my CSS, one being centeredRight and one centeredLeft. They are lined up down the page. But my last div on the left seems to get pushed to the right.
Here is my CSS.
.centeredlistleft {
width: 300px;
margin: 0 auto;
text-align: left;
border: 2px solid;
float: left;
margin-bottom: 25px;
padding-right: 10px;
}
.centeredlistright {
width: 300px;
margin: 0 auto;
text-align: left;
border: 2px solid;
float: right;
margin-bottom: 25px;
padding-right: 10px;
}
.body {
margin: 0 auto;
padding: 0;
text-align: center;
color: purple;
background-color: pink;
}
And here is my HTML.
<div id="sandrcontainer" class="body" style="width:700px">
<div id="onsieforbaby" class="centeredlistleft" >
<h3> Onesie for Baby </h3>
<ul>
<li>
Price
<ul>
<li>$10.00</li>
</ul>
</li>
<li>
Description
<ul>
<li>It's a boy onesie for a new baby boy. Carter onesies are used. Can ask for specific size. Can also make one for girls using pink.</li>
</ul>
</li>
</ul>
</div>
<div id="largetennistowel" class="centeredlistright">
<h3> Large Tennis Towel </h3>
<ul>
<li>
Price
<ul>
<li>$14.00</li>
</ul>
</li>
<li>
Size
<ul>
<li>16 x 26 (Inches)</li>
</ul>
</li>
<li>
Description
<ul>
<li> Cotton fleece. Very soft. Washes Well. Can be personalized. Check out the photo gallery for examples. Ask seller what color towels are available at time of order.</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="sandrcontainer2" class="body" style="width:700px">
<div id="largegolftowel" class="centeredlistleft">
<h3> Large Golf Towel </h3>
<ul>
<li>
Price
<ul>
<li>$14.00</li>
</ul>
</li>
<li>
Size
<ul>
<li>16 x 26 (Inches)</li>
</ul>
</li>
<li>
Description
<ul>
<li> Golf towel. Elegant. Large white towel. Cotton fleece. Very soft. Can be personalized. Check out photo gallery for examples. Ask seller what color towels are avaiable at time of order. This towel has a grommet and can be hung on golf bags. Could also make this on fingertipe towel for guest bath or on linen towel for that elegant look.</li>
</ul>
</li>
</ul>
</div>
<div id="terrysmalltowel" class="centeredlistright">
<h3> Terry Small Towel </h3>
<ul>
<li>
Price
<ul>
<li>$11.00</li>
</ul>
</li>
<li>
Size
<ul>
<li>11 x 18 (Inches)</li>
</ul>
</li>
<li>
Description
<ul>
<li> With fringe. Made of 100% cotton loop terry. Can be personalized. Check out photo gallery for examples. Ask seller what color towels are avaiable at time of order.</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="sandrcontainer3" class="body" style="width:700px">
<div id="contactmerands" class="centeredlistleft" >
<p> Please make sure to send me an email before any orders. I may not have the color towel you want but can always order more </p>
</div>
<div id="smallfingertip" class="centeredlistright" >
<h3> Small Fintertip Holiday Towel </h3>
<ul>
<li>
Price
<ul>
<li>$11.00</li>
</ul>
</li>
<li>
Size
<ul>
<li>11 x 18 (Inches)</li>
</ul>
</li>
<li>
Description
<ul>
<li> Terry small towel with decorated cat for xmas. Made of 100% cotton loop terry. Can be personalized. Check out photo gallery for examples. Ask seller what color towels are available at time of order.</li>
</ul>
</li>
</ul>
</div>
</div>
TLDR - ctrl f for "Contactmerands" and please explain to me why this box is getting pushed to the bottom RIGHT of the large golf towel box. It should appear under the large golf towel box just like the rest of the divs.
If you would like to see what I mean you can go to my school web portal where I have the page posted HERE.
When an element is floated, it is essentially removed from the flow of the document. Thus, when a parent element's children are all floated, the parent collapses upon itself as it doesn't have any defined dimensions.
To solve this, you could set either overflow:hidden or overflow:auto on the parent elements. This essentially forces it to contain the children elements, therefore preventing it from collapsing.
Add the following CSS and your problem is solved:
#sandrcontainer,
#sandrcontainer2,
#sandrcontainer3 {
overflow: hidden;
}
Sometimes changing the overflow property will conflict with existing CSS. You could alternatively use the pseudo element clearfix:
.clearfix:after {
content: '';
clear: both;
display: table;
}
You must clear your floats in order to achieve the desired effect.
I suggest using a valid clearfix for this.
You need to declare this in CSS:
.clearfix:after {
clear:both;
content:".";
display:block;
font-size:0;
height:0;
visibility:hidden;
}
.clearfix { display:block; }
Now wrap all your elements that should float next to each other in a DIV and apply the clearfix class:
<div class="clearfix">
<!-- put your divs here //-->
</div>
<!--put your last div here //-->
I have set this:
list-style: none outside none;
And HTML:
<ul class="menu custompozition4">
<li class="item-507">Strategic Recruitment Solutions
</li>
<li class="item-508">Executive Recruitment
</li>
<li class="item-509">Leadership Development
</li>
<li class="item-510">Executive Capability Review
</li>
<li class="item-511">Board and Executive Coaching
</li>
<li class="item-512">Cross Cultutral Coaching
</li>
<li class="item-513">Team Enhancement & Coaching
</li>
<li class="item-514">Personnel Re-deployment
</li>
</ul>
but even though bullets are displayed. (I'm not quite sure that those are ul's bullets, because when you hover the text the "bullets" get underlined.)
Image Demo:
https://i.imgur.com/2wsnBqP.png
The third level from the menu
Have you tried setting
li {list-style-type: none;}
According to Need an unordered list without any bullets, you need to add this style to the li elements.
You can remove the "bullets" by setting the "list-style-type: none;" Like
ul
{
list-style-type: none;
}
OR
<ul class="menu custompozition4" style="list-style-type: none;">
<li class="item-507">Strategic Recruitment Solutions
</li>
<li class="item-508">Executive Recruitment
</li>
<li class="item-509">Leadership Development
</li>
<li class="item-510">Executive Capability Review
</li>
<li class="item-511">Board and Executive Coaching
</li>
<li class="item-512">Cross Cultutral Coaching
</li>
<li class="item-513">Team Enhancement & Coaching
</li>
<li class="item-514">Personnel Re-deployment
</li>
</ul>
ul.menu li a:before, ul.menu li .item:before, ul.menu li .separator:before {
content: "\2022";
font-family: FontAwesome;
margin-right: 10px;
display: inline;
vertical-align: middle;
font-size: 1.6em;
font-weight: normal;
}
Is present in your site's CSS, looks like it's coming from a compiled CSS file from within your application. Perhaps from a plugin. Changing the name of the "menu" class you are using should resolve the issue.
Visual for you - http://i.imgur.com/d533SQD.png
In my case
li {
list-style-type : none;
}
It doesn't show the bullet but leaved some space for the bullet.
I use
li {
list-style-type : '';
}
It works perfectly.
In your css file add following.
ul{
list-style-type: none;
}
you can use it this way to
{
Fdata.map((point,index) =>(
<ul style ={{listStyle:'none'}}key={index} >
<li className="text_paragraph"style={{fontSize:"0.8rem",color:"#ff1100"}}>{point.list}</li>
</ul>
))
}
Try this it works
<ul class="sub-menu" type="none">
<li class="sub-menu-list" ng-repeat="menu in list.components">
<a class="sub-menu-link">
{{ menu.component }}
</a>
</li>
</ul>