Do not wrap text under icon list group - html

With this code, the text wraps under the icon. How can I make it so the text doesn't wrap under the icon while keeping the alignment together?
Thanks in advance!
.list-group-item {
width: 100%;
text-align: left;
background-color: #ffffff;
border-color: #ffffff;
color: #333;
padding-left: 0;
}
.fa-check-circle {
font-size: larger;
color: black;
vertical-align: middle;
padding-right: 5px;
}
<ul class="list-group">
<li class="list-group-item"><i class="far fa-check-circle"></i><span class="features">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</span></li>
</ul>

There are several ways to achive this - but the simplest is to remove the margins and padding on the ul, apply list-style:none to remove the native browser bulletfor the li's.
Then apply padding-left to the li to move it as a block and give it space on the left for the icon to sit into. Be sure to make it position: relative, since the icon will be positioned absolutely in relation to the li.
Then the icon can be made position: absolute and left: 0 in order to sit into the space in the li made by the left padding.
EDIT: There is a built in version of this via Font-Awesome which you can directly use to replace the bullets in the ul - refer to the bottom example. Only styling required is to space out the li's - but the icon in place of the bullet is handled by the FA styling.
.list-group {
margin-left: 0;
padding-left: 0;
list-style: none;
}
.list-group-item {
width: 100%;
background-color: #ffffff;
border-color: #ffffff;
color: #333;
padding-left: 32px;
position: relative;
margin-bottom: 12px
}
.fa-check-circle {
font-size: larger;
color: black;
vertical-align: middle;
position: absolute;
left: 0
}
.fa-ul li {
margin-bottom: 12px;}
<link rel="stylesheet" type="text/css" media="all"href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />
<b>Standard method - using spacing and position: absolute to position the icons.</b>
<ul class="list-group">
<li class="list-group-item">
<i class="far fa-check-circle"></i><span class="features">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</span>
</li>
<li class="list-group-item">
<i class="far fa-check-circle"></i><span class="features">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</span>
</li>
<li class="list-group-item">
<i class="far fa-check-circle"></i><span class="features">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</span>
</li>
</ul>
<hr/>
<b>Native Font-aesome method - replacing the bulets with icons</b>
<ul class="fa-ul">
<li><span class="fa-li"><i class="far fa-check-circle"></i></span>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</li>
<li><span class="fa-li"><i class="far fa-check-circle"></i></span>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</li>
<li><span class="fa-li"><i class="far fa-check-circle"></i></span>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</li>
</ul>

Related

How can i add shape background like on image using css? [duplicate]

This question already has an answer here:
How to create uneven rounded sides on a div?
(1 answer)
Closed 3 years ago.
I tried like this but it's not right solution. Any solutions for this issue please.
.shape {
width: 200px;
height: 100px;
position:absolute;
top: 0;
right: 0;
background: red;
-moz-border-radius: 0px 0px 20px 110px;
-webkit-border-radius: 0px 0px 20px 110px;
border-radius: 0px 0px 20px 110px;
}
<div class="shape"></div>
I have added a :pseudo element and postioned it
.bg-shape {
position: relative;
overflow: hidden;
padding: 50px;
}
.bg-shape:after {
content: '';
position: absolute;
width: 600px;
height: 600px;
background: red;
border-radius: 50%;
top: 0;
right: 0;
z-index: -1;
top: -60%; /* change value as required */
right: -20%; /* change value as required */
}
<div class="bg-shape">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
</p>
</div>

Alignment of content vertically in adjacent flexbox containers

I have multiple items say cards. These cards need to stack horizontally and height needs to be the same. This is happening for me.
Each card has an image, text and a button. Image and text for each card should take what ever is the max height in any card, so that these align properly. This is not happening for me.
If the image and text align properly then the button will always be aligned in each card at the bottom.
I have been following this tutorial but I have multiple cards, putting three here only. Also the third card image height is being set via CSS.
.partner-cards * {
box-sizing: border-box;
}
.partner-cards {
display: flex;
flex-wrap: wrap;
}
.partner-card {
display: flex;
flex: 1 0 20%;
border-radius: 0;
text-align: center;
border: 3px solid blue;
padding: 5px;/*3rem;*/
margin-bottom: 3rem;
max-width: 20%;
margin: 5px;
}
.partner-card-content {
display: flex;
flex-direction: column;
}
/*
.card-content .image-container img {
margin: 0;
padding: 0;
}
*/
.partner-card-content .partner-image-container {
border: 1px solid green;
padding: 0;
margin: 0;
min-height: 11rem;
display: flex;
vertical-align: middle;
align-items: center;
justify-content: center;
max-width: 100%;
}
.partner-card-content p /*, .card-content .image-container*/
{
flex: 1 0 auto;
border: 1px solid red;
}
.partner-card-content img.third-image {
height: 5.5rem !important;
}
/*
p {
font-size: 16px;
line-height: 26px;
font-family: Averta-Regular,Arial,Helvetica,sans-serif;
margin-bottom: 2.5rem;
margin-top: 0;
}*/
<div class="partner-cards">
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/100x40" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p>
<a class="primary-button" href="#">View XXX XXX XXX Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/50x150" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s.</p>
<a class="primary-button" href="#">View YYY Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/120x100" class="third-image" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
<a class="primary-button" href="#">View ZZZ Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/50x100" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
<a class="primary-button" href="#">View ABC Offer</a>
</div>
</div>
</div>
How it should show:
The tutorial image on code pen, properly aligns the h2, text and link:
TL;DR
Alignment of flexbox items in adjacent flexboxes is not possible in CSS. You really need sub-grids to solve this problem with dynamic sizes of the sections in your card.
Flexbox Scenario
Anyway given that you have a min-height for the partner-image-container, so I guess you can have either a min-height set for the a or an ellipsis to keep it to a single line. See below solution that adds an ellipsis:
.partner-cards * {
box-sizing: border-box;
}
.partner-cards {
display: flex;
flex-wrap: wrap;
}
.partner-card {
display: flex;
flex: 1 0 20%;
border-radius: 0;
text-align: center;
border: 3px solid blue;
padding: 5px;/*3rem;*/
margin-bottom: 3rem;
max-width: 20%;
margin: 5px;
}
.partner-card-content {
display: flex;
flex-direction: column;
min-width: 0; /* ADDED */
}
/*
.card-content .image-container img {
margin: 0;
padding: 0;
}
*/
.partner-card-content .partner-image-container {
border: 1px solid green;
padding: 0;
margin: 0;
min-height: 11rem;
display: flex;
vertical-align: middle;
align-items: center;
justify-content: center;
max-width: 100%;
}
.partner-card-content p/*, .card-content .image-container*/ {
flex: 1 0 auto;
border: 1px solid red;
}
.partner-card-content img.third-image {
height: 5.5rem !important;
}
/*
p {
font-size: 16px;
line-height: 26px;
font-family: Averta-Regular,Arial,Helvetica,sans-serif;
margin-bottom: 2.5rem;
margin-top: 0;
}*/
.primary-button { /* ADDED */
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
<div class="partner-cards">
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/100x40" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p>
<a class="primary-button" href="#">View XXX XXX XXX Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/50x150" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s.</p>
<a class="primary-button" href="#">View YYY Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/120x100" class="third-image" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
<a class="primary-button" href="#">View ZZZ Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/50x100" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
<a class="primary-button" href="#">View ABC Offer</a>
</div>
</div>
</div>
Note that you'll have to add min-width: 0 to partner-card-content to override the default min-width: auto setting for a flexbox in the flex axis. You can see some examples of this behaviour below:
Flexbox affects overflow-wrap behavior
Flexbox resize and scrollable overflow
Why don't flex items shrink past content size?
CSS Grid Scenario
You can do this in a different way using CSS Grid Layout - as an example consider 3 cards laid out in a row. This works for dynamic heights of each of your card sections - see demo below:
.partner-cards * {
box-sizing: border-box;
}
.partner-cards {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: auto 1fr auto;
grid-auto-flow: column;
grid-column-gap: 10px;
}
.partner-card, .partner-card-content {
display: contents;
}
.partner-card-content .partner-image-container {
border: 1px solid green;
display: flex;
align-items: center;
justify-content: center;
max-width: 100%;
}
.partner-card-content p {
border: 1px solid red;
margin: 0;
}
.partner-card-content a {
border: 1px solid;
}
<div class="partner-cards">
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/100x40" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p>
<a class="primary-button" href="#">View XXX XXX XXX Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/50x150" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s.</p>
<a class="primary-button" href="#">View YYY Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/120x100" class="third-image" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
<a class="primary-button" href="#">View ZZZ Offer</a>
</div>
</div>
</div>
But again it has limitations because you are not able to control your layout - you don't have control over your cards but you are working on the contents of the cards here which is not very useful. Note that I have used display: contents for the partner-card and partner-card-content elements. When sub-grids are implemented, we will have a complete solution to layouts such as this - see the discussion below too:
Wrap CSS grid with auto placement

Ordered list of items in pair

I have to show ordered listed items side by side in pairs with varying content size (generating the li's using angular ng-repeat from some model value). I have used bootstrap grid columns to manage the li content positioning.
problem is the numbering of li is getting very close with content of previous column. as in my case second li order number "2" is touching the content of first li. on inspecting I fount that the index number is outside of "col-sm-6". changing the padding-left of columns will fix this but I am looking for a better solution in bootstrap way.
/* highlight column border */
.col-sm-6 {
border: solid 1px red;
}
/* a fix for column displacement */
.col-sm-6:nth-child(odd) {
clear: left;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<ol class="row">
<li class="list-group-item2 col-sm-6">
Lorem Ipsum is simply dummy text of the printing and typesetting industr Lorem is text of the printing and typesetting industr
Lorem Ipsum is simply dummy text of the printing and typesetting industr Lorem Ipsum is simply dummy text
of the printing and typesetting industry.
</li>
<li class="list-group-item2 col-sm-6">
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</li>
<li class="list-group-item2 col-sm-6 label-warning">
Lorem Ipsum is simply dummy text of the printing and typesetting industr Lorem Ipsum is simply dummy text of the printing
and typesetting industr Lorem Ipsum is simply dummy text of the printing and typesetting industr Lorem Ipsum
is simply dummy text of the printing and typesetting industr Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of
the printing and typesetting industry.
</li>
<li class="list-group-item2 col-sm-6">
Lorem Ipsum is simply dummy text
</li>
<li class="list-group-item2 col-sm-6">
Lorem Ipsum is simply dummy text
</li>
<li class="list-group-item2 col-sm-6">
Lorem Ipsum is simply dummy text
</li>
</ol>
</div>
the best way is use list-style-position
ul {
list-style-position: inside;
}

How to limit character displayed with CSS using inline-blocks?

Does anyone know how to use the following css trick with inline-blocks?
.text {
display: block;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
I have couple of text tags (h2 & h3) on the same line and even if I change the display: block to inline-block, it still messes up the layout.
Has anyone done anything similar?
EDIT: I only want to concatenate the h2 (first element), not the h3 tag content.
try this
p{
display: inline-block;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<p class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
</p>
Try to use line-height for class text with display:inline-block
.text{
display: inline-block;
/* adjust line height for class text*/
line-height: 25px;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<h2 class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
</h2>
<h3 class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
</h3>
.text {
display: inline-block;
line-height:20px;
width: 200px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<h2 class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy.
</h2>
<h3 class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy.
</h3>

Move search box on the top by using CSS animation

I need to move my search box when user focus on it. I am using css animation and that is working but not working fine. I want to make like the current search box is moving up but right now it is seems like new search box is replacing the current search box.
$('input').focus(function(){
$('.search').addClass('fixed');
})
$('input').blur(function(){
$('.search').removeClass('fixed');
})
body{
margin:0
}
.banner{
height:200px;
background:#ff0000
}
.search{}
.search-bar{ height:50px; background:#666; padding-top:10px}
.search-bar input{width:100%; height:35px}
.animated{background:#fff; opacity:0; position:fixed; bottom:0; height:0px; transition:height 0.5s; width:100%}
.fixed .animated{ height:100%; opacity:1}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div>
<div class="banner">
</div>
<div class="search">
<div class="search-bar">
<input type="text">
</div>
<div class="animated">
<div class="search-bar">
<input type="text">
</div>
</div>
</div>
<div class="body">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
</div>
</div>
Here is a sample having the same animation using only 1 search box (input)
$('input').focus(function(){
$('.search').addClass('fixed');
})
$('input').blur(function(){
$('.search').removeClass('fixed');
})
html, body {
margin: 0
}
.banner {
height: 200px;
background: #ff0000
}
.search-bar {
height: 50px;
background: #666;
padding-top: 10px
}
.search-bar input {
width: 100%;
height: 35px
}
.search {
transition: bottom 0.5s, top 0.5s;
background: #ddd;
width: 100%;
min-height: 50px;
top: 200px;
bottom: 40%;
}
.search.fixed {
transition: bottom 0.5s, top 0.5s;
top: 0;
bottom: 0;
position: fixed;
width: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div>
<div class="banner">
</div>
<div class="search">
<div class="search-bar">
<input type="text">
</div>
</div>
<div class="body">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
</div>
</div>