I'm currently working on an unordered list containing list items with taglines. I'm having a problem concerning one list item, which is long enough to take up two lines (See image)
I want it so that the second line is aligned with the first line. This is the HTML code i'm using. I used fontAwesome for the check images.
ul {
width: 300px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<ul class="fa-ul custom-list">
<li><i class="fa fa-check fa-fw"></i>List item on 1 line</li>
<li><i class="fa fa-check fa-fw"></i>List item on 1 line</li>
<li><i class="fa fa-check fa-fw"></i>This is a list item that actually takes up 2 lines. Looks ugly</li>
</ul>
I already tried to enter multiple in between '2' and 'lines' but that seems like a really bad practice to me. I hope someone can help me with this problem.
This is because the tick is inline content so when the text wraps it will continue to flow as usual.
You can stop this behaviour by taking advantage of text-indent:
The text-indent property specifies how much horizontal space should be left before the beginning of the first line of the text content of an element.
text-indent (https://developer.mozilla.org/en-US/docs/Web/CSS/text-indent)
By supplying a negative text-indent you can tell the first line to shift a desired amount to the left. If you then specify a positive padding-left you can cancel this offset out.
In the following example a value of 1.28571429em is used because it is the width set on the .fa-fw by font-awesome.
ul {
width: 300px;
}
li {
padding-left: 1.28571429em;
text-indent: -1.28571429em;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<ul class="fa-ul custom-list">
<li><i class="fa fa-check fa-fw"></i>List item on 1 line</li>
<li><i class="fa fa-check fa-fw"></i>List item on 1 line</li>
<li><i class="fa fa-check fa-fw"></i>This is a list item that actually takes up 2 lines. Looks ugly</li>
</ul>
you can just add this to your ul:
ul {
text-indent:-20px;
margin-left:20px;
}
JSFIDDLE
You could remove the check out of the page flow by setting them with position:absolute
ul {
width: 300px;
}
.fa-fw {
position: absolute;
left: -22px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />
<ul class="fa-ul custom-list">
<li><i class="fa fa-check fa-fw"></i>List item on 1 line</li>
<li><i class="fa fa-check fa-fw"></i>List item on 1 line</li>
<li><i class="fa fa-check fa-fw"></i>This is a list item that actually takes up 2 lines. Looks ugly</li>
</ul>
You can use "display:table" as style for li, and inside create a span with "display:table-cell" styling. Or create corresponding class. Like this:
<li style="display:table"><span style="display:table-cell">text with
all lines indented</span></li>
you can put your text in a div and give float:left to your inner li and div.
ul li{
padding: 10px 0 10px 20px;
text-indent: -1em;
}
add padding and text indent - that moves the text from the li:before.
You can use list-style-position:outside. Do your CSS like this:
ul li {
list-style-position:outside;
... whatever else ...
}
or directly inline:
<li style = 'list-style-position:outside'>stuff </li>
ul li {
display: flex;
flex-direction: row;
}
ul li:before {
font: normal normal normal 14px/1 FontAwesome;
content: "\f054";
margin-right: 7px;
display: flex;
align-items: flex-start;
margin-top: 2px;
}
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<ul><li>Visit the Museum of Modern Art in Manhattan</li>
<li>Visit to Bali with tripraja</li>
<li>Check out Campbell's Soup Cans by Warhol and The Dance (I) by Matisse</li>
<li>Behold masterpieces by Gauguin, Dali, Picasso, and Pollock</li>
<li>Enjoy free audio guides available in English, French, German, Italian, Spanish, Portuguese.</li></ul>
Related
I want to know whether we can use Bootstrap icons for bullet points (using CSS) or not. I know that we can use FontAwesome to do that, but I just want to confirm if it is possible to do that using Bootstrap.
While I do know that we can use the following method :
<ul>
<li><i class="bi bi-check"></i> Buy Milk</li>
<li><i class="bi bi-check"></i> Buy Egg</li>
<li><i class="bi bi-check"></i> Buy Bread</li>
</ul>
I want to do it from CSS, just like this (An example using FontAwesome):
<style>
ul li:before {
font-family: 'FontAwesome';
content: '\f00c';
margin:0 5px 0 -15px;
color: #f00;
}
</style>
<ul>
<li>Buy Milk</li>
<li>Buy Egg</li>
<li>Buy Bread</li>
</ul>
I want to know how to do it using Bootstrap. If it is not possible then I can use either of the two methods above. If yes, then how do I do it?
Yes. Include the icon stylesheet in the head tag or #import in css file follow intruction from the site.
Then in :before, you declare font-family: bootstrap-icons !important; and content with whatever icon you want, ie the hearth icon will have the code as \F59E and so on.
div:before {
content: "\F59E";
font-family: bootstrap-icons !important;
font-style: normal;
font-weight: normal !important;
font-variant: normal;
text-transform: none;
line-height: 1;
vertical-align: -.125em;
margin-right: 5px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.10.3/font/bootstrap-icons.css" rel="stylesheet"/>
<div>+1</div>
My answer might get you some more flexibility. You can use custom counters for any style type.
li {
list-style-type: thumbs;
}
#counter-style thumbs {
system: cyclic;
symbols: 😍 😂 😒;
suffix: " ";
}
<ul>
<li><i class="bi bi-check"></i> Buy Milk</li>
<li><i class="bi bi-check"></i> Buy Egg</li>
<li><i class="bi bi-check"></i> Buy Bread</li>
</ul>
you can add any type of symbols you like.
I am currently creating a list this should instead of the default element ● would like to have a chevron right like in the example photo. However, I do not use bootstrap but Bulma. Is there an option to get this somehow without bootstrap. I did it with the character >. However, this one is not as nice as the chevron right .
So my question how can I replace the character '>' with such a 'chevron right' without using bootstrap?
chevron right
HTML
<ul className="footer-link">
<li>
First 1
</li>
<li>
Second 1
</li>
<li>
Third 1
</li>
</ul>
CSS
.footer-link ul {
list-style: none;
margin-left: 0;
padding-left: 0;
}
.footer-link ul li {
padding-left: 1em;
text-indent: -1em;
}
.footer-link li:before {
content: ">";
padding-right: 5px;
}
What I want
The chevron in this example is isosceles and moreover it is centered from the text height.
Example
<i class="bi bi-chevron-right"></i>
How about using the ::marker pseudo element? See https://developer.mozilla.org/en-US/docs/Web/CSS/::marker
It seems to be relatively new, so keep browser support in mind: https://caniuse.com/css-marker-pseudo
An example:
ul li::marker {
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f054";
}
<ul>
<li>First item</li>
<li>Second item</li>
</ul>
<!-- This is just needed to that I can use FontAwesome here on SO -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" referrerpolicy="no-referrer" />
are you allowed to use font awesome?
<script src="https://use.fontawesome.com/releases/v5.0.0/js/all.js"></script>
<ul class="fa-ul">
<li><span class="fa-li"><i class="fas fa-chevron-down"></i></span>First 1</li>
<li><span class="fa-li"><i class="fas fa-chevron-down"></i></span>Second 1</li>
<li><span class="fa-li"><i class="fas fa-chevron-down"></i></span>Third 1</li>
</ul>
I'm using a service which doesn't allow me to modify the code, but I"m able to add my own CSS. I am trying to change the CSS of a specific Link inside a li.
Here is my code:
<div class="kn-menu kn-view view_81" id="view_81">
<ul class="kn-tab-menu kn-grid-6">
<li class="kn-link-1"><span><i class="fa fa-bullseye"></i> I'm On Site</span></li>
<li class="kn-link-2"><span><i class="fa fa-pencil-square-o"></i> 1. Onsite Staff Signature</span></li>
<li class="kn-link-3"><span><i class="fa fa-pencil"></i> 2. Service/Signature</span></li>
<li class="kn-link-4"><span><i class="fa fa-ban"></i> 3. N/A - R</span></li>
<li class="kn-link-5"><span>Add Comments</span></li>
<li class="kn-link-6"><span><i class="fa fa-check"></i> 4. Completed</span></li>
</ul>
</div>
I want to select only the very first list item and tweak the css settings of the link within it - I want to make the background color and text different. Using the following allows me to change somethings but not the actual text within that li.
.kn-link-1 {
}
I also want to make sure that this change only happens for this specific instance where the parent id="view_81".
Can someone help find the right way to select just that
CSS is not the right place where you should change the content, anyway if you have no other choice, you could use the :after selector to do the following trick:
#view_81 > ul > li:nth-child(1) > a > span {
display: none;
}
#view_81 > ul > li:nth-child(1) > a:after {
background-color: red;
content: "your text";
}
<div class="kn-menu kn-view view_81" id="view_81">
<ul class="kn-tab-menu kn-grid-6">
<li class="kn-link-1"><span><i class="fa fa-bullseye"></i> I'm On Site</span>
</li>
<li class="kn-link-2"><span><i class="fa fa-pencil-square-o"></i> 1. Onsite Staff Signature</span>
</li>
<li class="kn-link-3"><span><i class="fa fa-pencil"></i> 2. Service/Signature</span>
</li>
<li class="kn-link-4"><span><i class="fa fa-ban"></i> 3. N/A - R</span>
</li>
<li class="kn-link-5"><span>Add Comments</span>
</li>
<li class="kn-link-6"><span><i class="fa fa-check"></i> 4. Completed</span>
</li>
</ul>
</div>
have you tried:
#view_81 ul li.kn-link-1
or
#view_81 ul li:first-child
To clarify my examples: "#" selector in CSS means "the one with the following ID" and then i'm telling the "ul" that comes after that and then the "li" that comes after that which has this class "kn-link-1" or which is the first item inside the tag (:first-child subselector).
I hope some of them help.
use this style:
li:first-of-type span
{
}
also be sure that your style link is last in your style references. If this does not help, declare your styles with "!important" like here:
li:first-of-type span
{
color:red !important;
}
using the selectors: #view_81 .kn-link-1 a targets the element with id="view_81" and the descendant element with class="kn-link-1" and the a tag inside that to change the background and text color.
#view_81 .kn-link-1 > a {
background: red;
color: yellow;
}
<div class="kn-menu kn-view view_81" id="view_81">
<ul class="kn-tab-menu kn-grid-6">
<li class="kn-link-1"><span><i class="fa fa-bullseye"></i> I'm On Site</span></li>
<li class="kn-link-2"><span><i class="fa fa-pencil-square-o"></i> 1. Onsite Staff Signature</span></li>
<li class="kn-link-3"><span><i class="fa fa-pencil"></i> 2. Service/Signature</span></li>
<li class="kn-link-4"><span><i class="fa fa-ban"></i> 3. N/A - R</span></li>
<li class="kn-link-5"><span>Add Comments</span></li>
<li class="kn-link-6"><span><i class="fa fa-check"></i> 4. Completed</span></li>
</ul>
</div>
I would stylize the css like this:
<style>
#view_81 .kn-link-1{
padding: 50px;
background-color: gray;
}
#view_81 .kn-link-1 a{
text-decoration: none;
}
#view_81 .kn-link-1 span{
color: white;
font-weight: bold;
text-shadow: 1px 2px 2px black;
}
</style>
This css only applies to the class .kn-link-1 within id #view_81.
I added a little basic css for your testing purposes, but you get the point.
I've attempted to replace fa icons on blogger with custom icons using
.fa-facebook{content:url("")}
The images work on Chrome but not FF or IE.
What's going on/Is there a workaround?
Jsfiddle
According to W3school:
Definition and Usage
The content property is used with the :before and :after
pseudo-elements, to insert generated content.
So instead of .fa-facebook{content:url("")} use .fa-facebook:before{content:url("")}
Jsfiddle
According to the official rules, the content property only works for ::before and ::after pseudo-elements. So in this case, Chrome breaks the rules!
Solution: add ::before to the selectors for the icons, then it will work in all browsers.
.fa-facebook::before {
content: url("https://lh3.googleusercontent.com/-VPr8buUo47w/VjMsRPIzr-I/AAAAAAAAAL4/AYBtvlNCQiw/s64-Ic42/clouds_social_media_icons_set_64x64_0000_facebook.png");
}
.fa-twitter::before {
content: url("https://lh3.googleusercontent.com/-yDH1FuHcQ5s/VjMsQ2lXvxI/AAAAAAAAAMg/i8JHsTh6aU8/s64-Ic42/clouds_social_media_icons_set_64x64_0002_twitter.png");
}
.fa-instagram::before {
content: url("https://lh3.googleusercontent.com/-VIveL13ocQc/VjMw7JU6dGI/AAAAAAAAAOo/AGxBey6rtC0/s64-Ic42/clouds_social_media_icons_set_64x64_0001_instagram.png")
}
.fa-pinterest::before {
content: url("https://lh3.googleusercontent.com/-Or5qfrW2PFI/VjMsQziUH5I/AAAAAAAAAL8/bOIkRNtMSbo/s64-Ic42/clouds_social_media_icons_set_64x64_0001_pinterest.png");
}
.fa-google-plus::before {
content: url("https://lh3.googleusercontent.com/-xIroPQ5PdBk/VjMsRhd-1VI/AAAAAAAAAMM/rcruNIarpPU/s64-Ic42/clouds_social_media_icons_set_64x64_0003_google%25252B.png");
}
.fa-heart::before {
content: url("https://lh3.googleusercontent.com/-ymc-N9bHkpo/VjNAMkaZnpI/AAAAAAAAAPY/Yv1qLXXuG7E/s64-Ic42/clouds_social_media_icons_set_64x64_0001_bloglovin.png");
}
<ul class="site-social-networks secondary-2-primary style-default show-title">
<li><i class="fa fa-facebook"></i>Facebook
</li>
<li><i class="fa fa-twitter"></i>Twitter
</li>
<li><i class="fa fa-instagram"></i>Instagram
</li>
<li><i class="fa fa-pinterest"></i>Pinterest
</li>
<li><i class="fa fa-heart"></i>Bloglovin
</li>
<li><i class="fa fa-google-plus"></i>Google Plus
</li>
</ul>
Use image in background instead of content for e.g
.fa-facebook{
content: '';
background:url("https://lh3.googleusercontent.com/-VPr8buUo47w/VjMsRPIzr-I/AAAAAAAAAL4/AYBtvlNCQiw/s64-Ic42/clouds_social_media_icons_set_64x64_0000_facebook.png");
width:64px;
height:64px;
display:inline-block;
}
I want to replace this line and show a custom image.
<i class="fa-solid fa-graduation-cap fa-lg">
Im have 3 columns with list items, and I dont understand why my first column (#col1) have a margin-right tha the other columns dont have.
I want that the margin-right is icual for all of my columns but Im not having sucesso doing this.
Do you see where might be the problem?
My jsfiddle with the problem:
http://jsfiddle.net/ritz/r2Y6d/4/
my html:
<div id="body-content">
<h1>Title</h1>
<img src="image1.jpg" width="700px" height="360px" />
<div id="info">
<h1>Info</h1>
<ul id="col1">
<li><i class="fa fa-phone" title="phone"></i>Phone</li>
<li><i class="fa fa-print" title="Fax"></i>Phone</li>
</ul>
<ul id="col2">
<li><i class="fa fa-home" title="adress"></i> Adress</li>
<li ><i class="fa fa-map-marker" title="Map"></i><a class="button" href="#showMap"><span>Show map</span></a></li>
</ul>
<ul id="col3">
<li><i class="fa fa-envelope-o" title="phone"></i>Email</li>
<li><i class="fa fa-envelope-o" title="Email"></i>Email</li>
</ul>
</div>
My css:
#info h1{color:red; font-size:23px; margin-bottom:0;}
#info ul {list-style:none;}
#info ul li a {text-decoration:none; color:#000;}
#col1{float:left; width:295px;font-size:16px; color:#000; margin-right:0;}
#col2{float:left; margin-right:50px;}
Is THIS what you are trying to do?
I removed the width:295px;, margin-right:0; and add #col3{float:left;}
Your first column, #col1, doesn't have a right margin, because you set margin-right:0; to it.
Rather, your uls have a left padding on them, which is set by default by the browser (left margin on IE 7, all other browsers are left padding.)
To remove the default, you need to add two properties to your rule:
#info ul {list-style:none; margin-left: 0; padding-left: 0; }
http://jsfiddle.net/r2Y6d/5/
That will get rid of the left margin.
However, it does look like tabular data. If you don't know already, the most semantic HTML structure for tabular data is a <table>. Or, if it's simple data-value pairs, you could use a definition list (<dl>).