flex - max-width does not cause text to wrap in IE10 - css

Why text is not wrapping in IE10?
body{
background: url(http://i.imgur.com/ilgJJ1Q.gif);
margin: 0;
}
ul{
margin: 0;
padding: 0;
list-style: none;
display: flex;
height: 80px;
}
li{
display: flex;
}
ul a {
color: #fff;
display: flex;
-webkit-align-items: center;
align-items: center;
max-width: 240px;
padding: 12px 50px;
align-items: center;
text-transform: uppercase;
text-decoration: none;
}
li img{
border: 0;
margin-right: 10px;
}
li span span {
display: block;
height: 2px;
margin: 7px 0 -7px;
width: 25px;
}
li:last-child{
background: rgba(38, 46, 54, .6);
}
li:nth-child(2){ background: #a15796; }
li:nth-child(3){ background: #b48c4d; }
li:nth-child(4){ background: #3a7d7d; }
<ul class="top-level-tax">
<li>
<a href="#" >
<img src="http://i.imgur.com/SRVh4os.png">
<span>Lorem ipsum dolor<span style="background-color: #38729c;"></span></span>
</a>
</li>
<li>
<a href="#" >
<img src="http://i.imgur.com/rBM2CYr.png">
<span>consectetur adipisicing<span style="background-color: #a05995;"></span></span>
</a>
</li>
<li>
<a href="#" class="" >
<img src="http://i.imgur.com/9dFFuH5.png">
<span>Mollitia harum<span style="background-color: #b38c51;"></span></span>
</a>
</li>
<li>
<a href="#" >
<img src="http://i.imgur.com/7bQ73kd.png">
<span>veritatis ea ipsa<span style="background-color: #3d7d7d;"></span></span>
</a>
</li>
</ul>
https://jsfiddle.net/afelixj/79pybrh9/1/

Add max-width to the span
li span{
display: block;
max-width: 120px;
}

You need to add flex-wrap: wrap; on your <ul> to specify you want it to wrap its content.

Related

build a timeline using CSS

I'm trying to achieve the following:
The problem I still have is the line before the first element and after the last element should be hidden.
The second issue is that the numbers are not vertically centered even when I use a flexbox with align-items and justify-content, if I zoom the picture a bit you can see that there is some difference:
The difference without zooming is about 2px~3px.
This is what I tried:
.container {
margin-top: 60px;
position: relative;
}
ol {
counter-reset: section;
list-style-type: none;
border-top: 1px solid #D9DEEA;
padding: 0;
margin: 36px 0 210px 0;
}
li {
float: left;
width: 20%;
padding-top: calc(58px / 2);
position: relative;
font-family: 'Antonio', sans-serif;
font-weight: 700;
display: flex;
flex-direction: column;
align-items: center;
}
li::before {
counter-increment: section;
content: counters(section, ".") " ";
width: 56px;
height: 56px;
background: #fff;
border: 2px dashed #D9DEEA;
border-radius: 50%;
box-shadow: 0 0 0 6px #fff;
position: absolute;
top: -30.5px;
left: calc(50% - 30px);
display: flex;
justify-content: center;
align-items: center;
line-height: 34px;
font-size: 24px;
}
.title {
margin: 6px 0;
line-height: 30px;
letter-spacing: -0.77px;
font-size: 25px;
display: block;
text-align: center;
}
.illustration {
display: block;
width: 165px;
height: 140px;
display: flex;
align-items: center;
justify-content: center;
background-color: #E6E9F0;
}
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Antonio:wght#300;400;700&family=Roboto:wght#300;400;500;700&display=swap" rel="stylesheet">
<section class="container">
<ol>
<li>
<span class="title">Lorem.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
<li>
<span class="title">Lorem, ipsum.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
<li>
<span class="title">Lorem, ipsum dolor.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
<li>
<span class="title">Lorem ipsum.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
<li>
<span class="title">Lorem, ipsum dolor.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
</ol>
</section>
I finally found a solution for the first issue.
The idea is to use a pseudo-element for ol that will act as a border with limited width.
.container {
margin-top: 60px;
position: relative;
}
ol {
counter-reset: section;
list-style-type: none;
padding: 0;
margin: 36px 0 0 0;
}
ol::before {
content: "";
display: block;
background: #D9DEEA;
position: absolute;
top: 0;
left: 10%;
height: 1px;
width: 80%;
}
li {
float: left;
width: 20%;
padding-top: calc(58px / 2);
position: relative;
font-family: 'Antonio', sans-serif;
font-weight: 700;
display: flex;
flex-direction: column;
align-items: center;
}
li::before {
counter-increment: section;
content: counters(section, ".") " ";
width: 56px;
height: 56px;
background: #fff;
border: 2px dashed #D9DEEA;
border-radius: 50%;
box-shadow: 0 0 0 6px #fff;
position: absolute;
top: -30.5px;
left: calc(50% - 30px);
display: flex;
justify-content: center;
align-items: center;
line-height: 34px;
font-size: 24px;
}
.title {
margin: 6px 0;
line-height: 30px;
letter-spacing: -0.77px;
font-size: 25px;
display: block;
text-align: center;
}
.illustration {
display: block;
width: 165px;
height: 140px;
display: flex;
align-items: center;
justify-content: center;
background-color: #E6E9F0;
}
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Antonio:wght#300;400;700&family=Roboto:wght#300;400;500;700&display=swap" rel="stylesheet">
<section class="container">
<ol>
<li>
<span class="title">Lorem.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
<li>
<span class="title">Lorem, ipsum.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
<li>
<span class="title">Lorem, ipsum dolor.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
<li>
<span class="title">Lorem ipsum.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
<li>
<span class="title">Lorem, ipsum dolor.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
</ol>
</section>
I'm not sure how to fix your problem with the styling of the li::before element, but here is a solution for your timeline not extending past 1 or 5. Add a ::before element to the ol element.
Edit: Solution was sourced from Border length smaller than div width?
.container {
margin-top: 60px;
position: relative;
}
ol {
counter-reset: section;
list-style-type: none;
padding: 0;
margin: 36px 0 210px 0;
}
ol::before {
content: "";
height: 10px;
width: 90%;
position: absolute;
top: -10px;
left: 5%;
/* or 100px */
border-bottom: 1px solid magenta;
}
li {
float: left;
width: 20%;
padding-top: calc(58px / 2);
position: relative;
font-family: 'Antonio', sans-serif;
font-weight: 700;
display: flex;
flex-direction: column;
align-items: center;
}
li::before {
counter-increment: section;
content: counters(section, ".") " ";
width: 56px;
height: 56px;
background: #fff;
border: 2px dashed #D9DEEA;
border-radius: 50%;
box-shadow: 0 0 0 6px #fff;
position: absolute;
top: -30.5px;
left: calc(50% - 30px);
display: flex;
justify-content: center;
align-items: center;
line-height: 34px;
font-size: 24px;
}
.title {
margin: 6px 0;
line-height: 30px;
letter-spacing: -0.77px;
font-size: 25px;
display: block;
text-align: center;
}
.illustration {
display: block;
width: 165px;
height: 140px;
background: url("../Images/API_EDI/catalog-bg.png") no-repeat center center;
display: flex;
align-items: center;
justify-content: center;
background-color: #E6E9F0;
}
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Antonio:wght#300;400;700&family=Roboto:wght#300;400;500;700&display=swap" rel="stylesheet">
<section class="container">
<ol>
<li>
<span class="title">Lorem.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
<li>
<span class="title">Lorem, ipsum.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
<li>
<span class="title">Lorem, ipsum dolor.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
<li>
<span class="title">Lorem ipsum.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
<li>
<span class="title">Lorem, ipsum dolor.</span>
<span class="illustration">
<img src="" alt="">
</span>
</li>
</ol>
</section>

wrapping text in flexbox

is it possible to wrap text in flex within a fixed width container?
so it looks like
img username added
you as a friend
rather than
user added
img name you as
a
friend
I can do this if the image and a were separate, but since they both link to the same thing, I wanna see if it can be done in the same tag.
ul {
width: 150px;
height: 300px;
border: solid 1px #000;
}
li {
display: flex;
align-items: center;
justify-content: center;
}
li img {
width: 25px;
height: 25px;
}
li a {
display: flex;
align-items: center;
text-decoration: none;
}
li span {
margin: 0 8px;
}
<ul>
<li>
<a href="https://placeholder.com">
<img src="http://via.placeholder.com/350x150"> <span> Username </span>
</a>
<p> added you as a friend</p>
</li>
</ul>
ul {
width: 150px;
height: 300px;
border: solid 1px #000;
padding: 5px;
}
li {
display: flex;
align-items: center;
justify-content: center;
}
li img {
width: 25px;
height: 25px;
}
li a {
display: flex;
align-items: center;
text-decoration: none;
}
li span {
margin: 0 8px;
}
<ul>
<li>
<a href="https://placeholder.com">
<img src="http://via.placeholder.com/350x150"> <span> Username </span>
</a>
<p> added you as a friend</p>
</li>
</ul>
Maybe the flex-wrap property would be useful in your case. Check this link for more information
https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap

Fixing Icon Size on Browser Zoom (with Chrome)

i just found an issue on my web project and i couldnt find a way around it.
i saw something about sprites and a blog that mentions this issue.
everything looks fine on 100% but when i zoom in with my browser the icons get bigger and bigger and break the layout.
this is what my css look like
.Sidebar {
position: fixed;
background-color: #262626;
width: 5%;
height: 100%;
z-index: 1;
}
.Sidebar-Icon {
align-items: center;
font-size: 30px;
}
.Sidebar-Icon .SDIcon {
text-decoration-line: none;
}
.Sidebar-Icon li {
list-style-type: none;
}
ul.Sidebar-Icon {
cursor: pointer;
display: flex;
padding: 0;
flex-direction: column;
align-items: center;
flex: 1;
margin: 0;
height: 100%;
position: relative;
}
.Sidebar-Icon li:first-child{
padding: 20px 0 0 0;
}
.Sidebar-Icon li:first-child,
.Sidebar-Icon li:last-child{
margin-bottom:auto;
}
.sb-i{
color: #999AAA !important; // shadow AAABBB
}
Html (Angular) Code
<div class="Sidebar" [#collapse]="collapse">
<div class="Sidebar-Inner">
<div class="profileimg"></div>
</div>
<ul class="Sidebar-Icon ">
<li><a class="sb-i" (click)="toggleCollapse()">
<i class="fas fa-ellipsis-v" ></i></a></li>
<li><a class="sb-i"href="javascript:void(0)"><i class="fas fa-home"></i></a>
</li>
<li><a class="sb-i"href="javascript:void(0)"><i class="fas fa-child"></i>
</a></li>
<li><a class="sb-i"href="javascript:void(0)"><i class="fab fa-accessible-
icon"></i></a></li>
<li><a class="sb-i"href="javascript:void(0)"><i class="fas fa-cog"></i></a>
</li>
</ul>
</div>
example of the issue (Zoomlevel on 500%):
HTML:
<div class="Sidebar" [#collapse]="collapse">
<div class="Sidebar-Inner">
<div class="profileimg"></div>
</div>
<ul class="Sidebar-Icon ">
<li><a class="sb-i" (click)="toggleCollapse()">
<i class="fas fa-ellipsis-v" ></i></a></li>
<li><a class="sb-i" href="javascript:void(0)"><i class="fas fa-home"></i></a>
</li>
<li><a class="sb-i" href="javascript:void(0)"><i class="fas fa-child"></i>
</a></li>
<li><a class="sb-i" href="javascript:void(0)"><i class="fab fa-accessible-
icon"></i></a></li>
<li><a class="sb-i" href="javascript:void(0)"><i class="fas fa-cog"></i></a>
</li>
</ul>
</div>
CSS:
.Sidebar {
position: fixed;
background-color: #262626;
width: 5%;
height: 100%;
z-index: 1;
}
.Sidebar-Icon {
align-items: center;
font-size: 30px;
}
.Sidebar-Icon .SDIcon {
text-decoration-line: none;
}
.Sidebar-Icon li {
list-style-type: none;
}
ul.Sidebar-Icon {
cursor: pointer;
display: flex;
padding: 0;
flex-direction: column;
align-items: center;
flex: 1;
margin: 0;
height: 100%;
position: relative;
}
.Sidebar-Icon li:first-child{
padding: 20px 0 0 0;
}
.Sidebar-Icon li:first-child,
.Sidebar-Icon li:last-child{
margin-bottom:auto;
}
.sb-i{
color: #999AAA !important; // shadow AAABBB
}
.sb-i i{
width: 100%;
height: auto;
}
.sb-i svg {
width: 100% !important;
height: auto !important;
}

positioning the text in the center of li tag

I have created three blocks using the html code as shown below. The "a" tag has the min-height css property because of which it will be displayed as block. I am not able to place the text inside the span tag in the center of "li" tag. Although each text inside the tag is of different length, I want to display them in the center.
<div class="container">
<div class="col-md-12">
<ul id="tabs" class="nav-tabs">
<li class="col-md-4 nav-list">
<a href="#" class="nav-block">
<span class="header">Data</span>
</a>
</li>
<li class="col-md-4 nav-list">
<a href="#" class="nav-block">
<span class="header">Charts</span>
</a>
</li>
<li class="col-md-4 nav-list">
<a href="#" class="nav-block">
<span class="header">Reports</span>
</a>
</li>
</div>
</div>
CSS:
.container ul {
list-style: none outside none;
}
li {
display: list-item;
}
.col-md-4 {
width: 33%;
}
.nav-block {
background-color: #FFA500;
display: block;
min-height: 70px;
position: relative;
}
.container .nav-block .header {
color: #FFFFFF;
font-size: 2em;
font-weight: bold;
left: 20%;
padding: 5px;
position: relative;
text-align: center;
top: 21%;
}
Please let me know where I am going wrong
just changed the css to center the texts, check in the fiddle
.nav-block {
background-color: #FFA500;
display: block;
min-height: 70px;
position: relative;
text-align: center;
}
.container .nav-block .header {
color: #FFFFFF;
font-size: 2em;
font-weight: bold;
padding: 5px;
position: relative;
text-align: center;
top: 21%;
}
You should set the text-align:center; on the li{}
And delete the position:relative; on .container .nav-block .header {
DEMO
With editting my sugestions you have a shorter css, because you can delete the unaccecary things. Like here.
.container .nav-block .header {
color: #FFFFFF;
font-size: 2em;
font-weight: bold;
padding: 5px;
}
DEMO 2 (same as the other but less css)
Try this below css.
.nav-block {
background-color: #FFA500;
display: block;
min-height: 70px;
position: relative;
text-align: center; /*New Edit*/
}
.container .nav-block .header {
color: #FFFFFF;
font-size: 2em;
font-weight: bold;
/*left: 20%; - Remove*/
padding: 5px;
position: relative;
text-align: center;
top: 21%;
}
just add text-align:center; to .nav-tabs or .nav-block
You aren't closing your <ul> tag.
I hope this is what you want ->
DEMO
HTML
<div class="container">
<div class="col-md-12">
<ul id="tabs" class="nav-tabs">
<li class="col-md-4 nav-list">
<a href="#" class="nav-block">
<span class="header">Data</span>
</a>
</li>
<li class="col-md-4 nav-list">
<a href="#" class="nav-block">
<span class="header">Charts</span>
</a>
</li>
<li class="col-md-4 nav-list">
<a href="#" class="nav-block">
<span class="header">Reports</span>
</a>
</li>
<!--closing the ul tag-->
</ul>
</div>
</div>
CSS
.container ul {
list-style: none outside none;
}
li {
display: list-item;
}
.col-md-4 {
width: 33%;
}
.nav-block {
background-color: #FFA500;
display: block;
min-height: 70px;
position: relative;
text-align:center; /*aligning the text center*/
line-height:60px; /*this gives vertical alignment to your element*/
}
.container .nav-block .header {
color: #FFFFFF;
font-size: 2em;
font-weight: bold;
left: 0; /*removed the defined 20% to center you text inside anchor <a> tags*/
padding: 5px;
position: relative;
text-align: center;
top: 21%;
}

div`s display block inside li element makes it have empty space

I have following code:
<div class="settingsMenu" style="top: 135px; left: 149px; display: block;">
<ul>
<li class="download" onclick="downTemplate('template1')">Download</li>
<li class="delete" onclick="showConfirmationDialog ($(this))">
Delete
<div class="deleteItemConfirmation">
<div class="confirmationText">Are you sure?</div>
<div class="buttons"><button onclick="deleteTemplate ('template1')">Yes</button> <button onclick="hideConfirmationDialog();">No</button></div>
</div>
</li>
<li class="info">Info</li>
</ul>
</div>
CSS:
.settingsMenu{
position: absolute;
top: 0;
left: 0;
display: none;
background-color: #FFFFFF;
border: 1px solid #b5044a;
border-radius: 5px;
width: 150px;
padding: 10px 0;
margin: 0;
z-index: 200;
}
.settingsMenu ul{
list-style-type: none;
width: 100%;
margin: 0px;
padding: 0;
}
.settingsMenu ul li {
color: #000000;
cursor: pointer;
float: left;
font-size: 14px;
font-weight: normal;
font-family: Arial;
height: 18px;
max-width: 100px;
margin: 5px 20px;
padding: 0;
display: block;
padding-left: 30px;
}
.settingsMenu ul li.edit{
background: url("../img/edit-context-menu-icon.svg") no-repeat scroll center left white;
}
.settingsMenu ul li.delete{
background: url("../img/delete-context-menu-icon.svg") no-repeat scroll center left white;
}
.settingsMenu ul li.info{
background: url("../img/info-context-menu-icon.svg") no-repeat scroll center left white;
}
Problem is: while div.deleteItemConfirmation has "display: none;" everything is displaying correctly, when it`s display property becomes "display: block;" strange space appears before text of
<li>Delete</li>
Try changing
<li class="delete" onclick="showConfirmationDialog ($(this))">
Delete
To
<li class="delete" onclick="showConfirmationDialog ($(this))">Delete
Could this help you out:
<ul>
<li>
one</li><li>
two</li><li>
three</li>
</ul>
or
<ul>
<li>one</li
><li>two</li
><li>three</li>
</ul>
or with comments...
<ul>
<li>one</li><!--
--><li>two</li><!--
--><li>three</li>
</ul>
I took the idea from http://css-tricks.com/fighting-the-space-between-inline-block-elements/ and helped me in a few similar situations.

Resources