I want to have a headline on the left side and buttons on the right side. Between I want a line.
.container {
background-image: url(http://www.deutsches-museum.de/fileadmin/Content/010_DM/020_Ausstellungen/100_Museumsinsel/030_Turm/030_Kunst/bild32.jpg);
height: 100px;
color: #fff;
}
.col-xs-8 {
border: 1px solid blue;
}
ul {
display: flex;
text-align: justify;
margin: 0;
padding: 0;
list-style-type: none;
}
ul li {
overflow: hidden;
white-space: nowrap;
}
li:first-child {
padding-right: 10px;
}
li:last-child {
padding-left: 10px;
font-size: 10px;
}
h2 {
margin: 10px 0 0 0;
font-size: 20px;
font-weight: normal;
}
.fa-stack-1x {
color: #777;
}
.line {
margin: 0 auto 5px;
border-bottom: 2px solid red;
width: 100%;
}
<div class="container">
<div class="row">
<div class="col-xs-8">
<div class="breadcrump">
<ul class="menu">
<li>
<h2>Here is a example Headline</h2>
</li>
<li class="line"></li>
<li>
<span class="fa-stack fa-lg">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa fa-chevron-left fa-stack-1x"></i>
</span>
<span class="fa-stack fa-lg">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa fa-chevron-right fa-stack-1x"></i>
</span>
</li>
</ul>
</div>
</div>
</div>
</div>
With justify the line overlays the Headline and the buttons and this is not what I want.
http://codepen.io/daluela/pen/aOVmGw
If I understand what you want, all you need to do is replace width:100% in .line with flex:1;.
Remove overflow:hidden from your list items.
http://codepen.io/anon/pen/gpXgRW
ul li {
overflow: hidden;/*remove this*/
white-space: nowrap;
}
Related
I am trying to design a nav-bar using flex-box, with bootstrap 4. I have three div and whenever the browser shrinks, the div's header__center and header__right are coming one another line. But I wanted to make them remain in the same line, no matter how small the size of the device.
Now when the device width is 576 to 614 i am getting this problem:
And when the device size is extra small that is <314, there is this problem
* {
margin: 0;
padding: 0;
}
nav.navbar {
align-content: center;
position: sticky;
background-color: white;
z-index: 100;
top: 0;
box-shadow: 0px 5px 8px -9px rgba(0, 0, 0, 75);
padding: 0px 20px;
/* REMOVED TOP PADDING */
}
.fas .fa-search {
color: #65676b;
}
.header__left>img {
height: 40px;
}
.header__left {
display: flex;
align-items: center;
}
.header__input {
display: flex;
align-items: center;
background-color: #eff2f5;
padding: 10px;
margin-left: 10px;
border-radius: 999px;
}
.header__input>input {
border: none;
background-color: transparent;
outline-width: 0;
padding-left: 10px;
}
.header__center {
display: flex;
flex-direction: row;
justify-content: center;
}
/*modified css */
.header__center__option {
list-style: none;
display: flex;
justify-content: space-between;
align-items: center;
list-style: none;
padding-left: 10px;
margin-bottom: 0;
height: 60px;
}
.header__center__item {
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-weight: 400;
padding: 0 2vw;
height: 60px;
margin-right: 8px;
box-shadow: inset 0 3px #f8f9fa, inset 0 -3px #f8f9fa;
}
.header__center__item.active,
.header__center__item.active:hover {
color: #1877f2;
/* border-bottom: 1px solid #1877f2;
border-bottom-width: 3px; */
background-color: #f8f9fa;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 0px;
}
.header__center__item:hover {
background-color: #e9ebef;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
}
.header_option-link {
flex-direction: column;
height: 52px;
display: flex;
text-decoration: none;
justify-content: center;
color: gray;
}
.header__center__item.active>.header_option-link {
color: #1877f2;
}
.header_option-link:hover {
color: gray;
}
.header__center__item.active {
color: #1877f2;
border-bottom: 1px solid #1877f2;
border-bottom-width: 3px;
background-color: #f8f9fa;
border-top-right-radius: 1px;
border-top-left-radius: 1px;
right: 2px;
left: 2px;
}
.header__info {
display: flex;
align-items: center;
padding-right: 12px;
margin-right: 8px;
border-bottom-left-radius: 18px;
border-top-right-radius: 18px;
border-bottom-right-radius: 18px;
border-top-left-radius: 18px;
padding-left: 12px;
cursor: pointer;
transition: background-color 0.2s ease-in-out;
}
.header__info__name {
font-size: 0.9375rem;
font-weight: 600;
color: #050505;
margin-top: -4px;
margin-bottom: -4px;
line-height: 1.3333;
}
.header__right {
display: flex;
}
.header__info>span {
margin-left: 10px;
}
.header__items {
display: flex;
align-items: center;
justify-content: center;
margin-right: 8px;
cursor: pointer;
width: 40px;
height: 40px;
background-color: #e4e6eb;
border-radius: 50%;
transition: background-color 0.2s ease-in-out;
transition-timing-function: cubic-bezier(0, 0, 1, 1);
}
.header__info img {
width: 28px;
height: 28px;
border-radius: 50%;
margin-left: -8px;
}
.header__info:hover {
background-color: #e4e6eb;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous" />
<nav class="navbar navbar-light bg-light py-xl-0 py-md-0 py-sm-0 py-2">
<div class="header__left">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Free_logo.svg/600px-Free_logo.svg.png" />
<div class="header__input">
<i class="fas fa-search"></i>
<input class="d-none d-xl-flex" placeholder="Search Facebook" type="text" />
</div>
</div>
<div class="header__center d-none d-xl-flex d-md-flex d-sm-flex">
<ul class="header__center__option">
<li class="header__center__item active">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-plane fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-bed fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-bus-alt fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-umbrella-beach fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-spa fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
</ul>
</div>
<div class="header__right">
<div class="header__info">
<img src="https://www.clipartkey.com/mpngs/m/118-1188761_avatar-cartoon-profile-picture-png.png"></img>
<span class="header__info__name">User</span>
</div>
<div class="header__items">
<i class="fas fa-envelope-open-text"></i>
</div>
</div>
</nav>
How to make those icons not to come in another line and be responsive to whatever the size the device width is decreased? Any help would be appreciated!
I am thinking to use the media query but stuck on the idea to start on what should be the approach or the techniques to make on that same line.
Remove padding-left: 10px on class header__center__option.
Remove all the class fa-lg on your icons.
Adding below stuff if you want to make it scrollable.
nav.navbar{
...
flex-wrap: nowrap;
overflow: auto;
}
https://jsfiddle.net/290478rf/1/
You just need to move header__left, header__center__option and header__right to one parent.
Change
<div class="header__left">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Free_logo.svg/600px-Free_logo.svg.png" />
<div class="header__input">
<i class="fas fa-search"></i>
<input class="d-none d-xl-flex" placeholder="Search Facebook" type="text" />
</div>
</div>
<div class="header__center d-none d-xl-flex d-md-flex d-sm-flex">
<ul class="header__center__option">
<li class="header__center__item active">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-plane fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-bed fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-bus-alt fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-umbrella-beach fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-spa fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
</ul>
</div>
<div class="header__right">
<div class="header__info">
<img src="https://www.clipartkey.com/mpngs/m/118-1188761_avatar-cartoon-profile-picture-png.png"></img>
<span class="header__info__name">User</span>
</div>
</div>
to
<div>
<div class="header__left">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Free_logo.svg/600px-Free_logo.svg.png" />
<div class="header__input">
<i class="fas fa-search"></i>
<input class="d-none d-xl-flex" placeholder="Search Facebook" type="text" />
</div>
</div>
<div class="header__center d-none d-xl-flex d-md-flex d-sm-flex">
<ul class="header__center__option">
<li class="header__center__item active">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-plane fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-bed fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-bus-alt fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-umbrella-beach fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-spa fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
</ul>
</div>
<div class="header__right">
<div class="header__info">
<img src="https://www.clipartkey.com/mpngs/m/118-1188761_avatar-cartoon-profile-picture-png.png"></img>
<span class="header__info__name">User</span>
</div>
</div>
</div>
Now hide and show header__center__item on respective breakpoints. This will fix both of your problems.
* {
margin: 0;
padding: 0;
}
nav.navbar {
align-content: center;
position: sticky;
background-color: white;
z-index: 100;
top: 0;
box-shadow: 0px 5px 8px -9px rgba(0, 0, 0, 75);
padding: 0px 20px;
overflow: hidden;
/* REMOVED TOP PADDING */
}
.fas .fa-search {
color: #65676b;
}
.header__left>img {
height: 40px;
}
.header__left {
display: flex;
align-items: center;
}
.header__input {
display: flex;
align-items: center;
background-color: #eff2f5;
padding: 10px;
margin-left: 10px;
border-radius: 999px;
}
.header__input>input {
border: none;
background-color: transparent;
outline-width: 0;
padding-left: 10px;
}
.header__center {
display: flex;
flex-direction: row;
justify-content: center;
}
/*modified css */
.header__center__option {
list-style: none;
display: flex;
justify-content: space-between;
align-items: center;
list-style: none;
padding-left: 10px;
margin-bottom: 0;
height: 60px;
}
.header__center__item {
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-weight: 400;
padding: 0 2vw;
height: 60px;
margin-right: 8px;
box-shadow: inset 0 3px #f8f9fa, inset 0 -3px #f8f9fa;
}
.header__center__item.active,
.header__center__item.active:hover {
color: #1877f2;
/* border-bottom: 1px solid #1877f2;
border-bottom-width: 3px; */
background-color: #f8f9fa;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 0px;
}
.header__center__item:hover {
background-color: #e9ebef;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
}
.header_option-link {
flex-direction: column;
height: 52px;
display: flex;
text-decoration: none;
justify-content: center;
color: gray;
}
.header__center__item.active>.header_option-link {
color: #1877f2;
}
.header_option-link:hover {
color: gray;
}
.header__center__item.active {
color: #1877f2;
border-bottom: 1px solid #1877f2;
border-bottom-width: 3px;
background-color: #f8f9fa;
border-top-right-radius: 1px;
border-top-left-radius: 1px;
right: 2px;
left: 2px;
}
.header__info {
display: flex;
align-items: center;
padding-right: 12px;
margin-right: 8px;
border-bottom-left-radius: 18px;
border-top-right-radius: 18px;
border-bottom-right-radius: 18px;
border-top-left-radius: 18px;
padding-left: 12px;
cursor: pointer;
transition: background-color 0.2s ease-in-out;
}
.header__info__name {
font-size: 0.9375rem;
font-weight: 600;
color: #050505;
margin-top: -4px;
margin-bottom: -4px;
line-height: 1.3333;
}
.header__right {
display: flex;
}
.header__info>span {
margin-left: 10px;
}
.header__items {
display: flex;
align-items: center;
justify-content: center;
margin-right: 8px;
cursor: pointer;
width: 40px;
height: 40px;
background-color: #e4e6eb;
border-radius: 50%;
transition: background-color 0.2s ease-in-out;
transition-timing-function: cubic-bezier(0, 0, 1, 1);
}
.header__info img {
width: 28px;
height: 28px;
border-radius: 50%;
margin-left: -8px;
}
.header__info:hover {
background-color: #e4e6eb;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous" />
<nav class="navbar navbar-light bg-light py-xl-0 py-md-0 py-sm-0 py-2">
<div class="header__left">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Free_logo.svg/600px-Free_logo.svg.png" />
<div class="header__input">
<i class="fas fa-search"></i>
<input class="d-none d-xl-flex" placeholder="Search Facebook" type="text" />
</div>
</div>
<div class="header__center d-none d-xl-flex d-md-flex d-sm-flex">
<ul class="header__center__option">
<li class="header__center__item active">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-plane fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-bed fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-bus-alt fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-umbrella-beach fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
<li class="header__center__item">
<a class="header_option-link text-decoration-none" href="#">
<i class="fas fa-spa fa-lg"></i>
</a>
<div class="header__option-line"></div>
</li>
</ul>
</div>
<div class="header__right">
<div class="header__info">
<img src="https://www.clipartkey.com/mpngs/m/118-1188761_avatar-cartoon-profile-picture-png.png"></img>
<span class="header__info__name">User</span>
</div>
<div class="header__items">
<i class="fas fa-envelope-open-text"></i>
</div>
</div>
</nav>
I'm looking to get the dots aligned, fixed, and should not move. This is what I need it to look like:
This is what I have so far below. As you can see if there are double digits, the dot moves.
This is what I'm rendering on the DOM. As you can see I have separated all three items into their own span.
<div className="Legend-Component col-3" align="center">
{legendData.map((item, index) => (
<ul key={index}>
<li>
<span className="Legend-Name" onClick={() => this.handleClick(item.assetManagerId)}>
{item.name}
</span>
<span className={`${item.className[index]}`}></span>
<span className="Legend-Total">{item.total}</span>
</li>
</ul>
))}
</div>
My CSS:
.Legend-Component ul {
list-style-type: none;
font-size: 12px;
text-align: right;
margin: auto;
}
.Legend-Name{
color: #006192;
cursor: pointer;
}
.Legend-Total {
font-weight: bold;
}
.navy {
display: inline-block;
width: 13px;
height: 13px;
background-color: #001f3f;
border-radius: 50%;
border: 1px solid grey;
}
.blue {
display: inline-block;
height: 13px;
width: 13px;
background-color: #0074D9;
border-radius: 50%;
border: 1px solid grey;
margin: 0 2px;
}
.aqua {
display: inline-block;
height: 13px;
width: 13px;
background-color: #7FDBFF;
border-radius: 50%;
border: 1px solid grey;
margin: 0 2px;
}
.teal {
display: inline-block;
height: 13px;
width: 13px;
background-color: #39CCCC;
border-radius: 50%;
border: 1px solid grey;
margin: 0 2px;
}
Make each list item a flex item. Allow the left and right elements to fill the available space with flex: 1.
This will keep the circles centred.
ul {
list-style: none;
padding: 0;
}
.circle {
display: inline-block;
height: 13px;
width: 13px;
border-radius: 50%;
border: 1px solid grey;
margin: 0 2px;
}
.blue {
background-color: #0074D9;
}
/* The important bits... */
.legend-item {
display: flex;
}
.legend-name {
flex: 1;
text-align: right;
}
.legend-total {
flex: 1;
}
<div className="Legend-Component col-3">
<ul key={index}>
<li class="legend-item">
<span class="legend-name">
Legend Name
</span>
<span class="circle blue"></span>
<span class="legend-total">00</span>
</li>
<li class="legend-item">
<span class="legend-name">
Legend Name
</span>
<span class="circle blue"></span>
<span class="legend-total">000</span>
</li>
<li class="legend-item">
<span class="legend-name">
Legend Name Long
</span>
<span class="circle blue"></span>
<span class="legend-total">0</span>
</li>
</ul>
</div>
If you need to align the circles off-centre, you may have to play with the flex-basis:
ul {
list-style: none;
padding: 0;
}
.circle {
display: inline-block;
height: 13px;
width: 13px;
border-radius: 50%;
border: 1px solid grey;
margin: 0 2px;
}
.blue {
background-color: #0074D9;
}
/* The important bits... */
.legend-item {
display: flex;
}
.legend-name {
flex: 1;
flex-basis: 100%;
text-align: right;
}
.legend-total {
flex: 1;
flex-basis: 50px;
}
<div className="Legend-Component col-3">
<ul key={index}>
<li class="legend-item">
<span class="legend-name">
Legend Name
</span>
<span class="circle blue"></span>
<span class="legend-total">00</span>
</li>
<li class="legend-item">
<span class="legend-name">
Legend Name
</span>
<span class="circle blue"></span>
<span class="legend-total">000</span>
</li>
<li class="legend-item">
<span class="legend-name">
Legend Name Long
</span>
<span class="circle blue"></span>
<span class="legend-total">0</span>
</li>
</ul>
</div>
I am trying to round font-awesome icon. Please refer - http://jsfiddle.net/JfGVE/1704/
The problem is, not matter what, the rounded icon is more oval. Not able to make it a perfectly rounded. Below is the css code i have -
i {
display: inline-block;
background: gray;
color: white;
border-radius: 50%;
padding: 5px;
}
It's preferable to avoid setting fixed width and height in pixels. Here's a sollution using an extra div with after pseudo element to draw the circle, see DEMO
HTML:
<div class="container">
<i class="fa fa-close"></i>
</div>
CSS:
.container {
display: inline-flex;
align-items: center;
justify-content: center;
background-color: #555;
min-width: 2em;
border-radius: 50%;
vertical-align: middle;
}
.container:after {
content:'';
float: left;
width: auto;
padding-bottom: 100%;
}
Try to adjust height/width and reset line-height:
i {
display: inline-block;
background: gray;
color: white;
border-radius: 50%;
padding: 0.3em; /* adjust padding */
line-height: initial !important; /* reset line-height */
height: 1em;
width: 1em;
text-align:center;
}
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
<i class="fa fa-close"></i>
<br>
<i class="fa fa-camera-retro fa-lg"></i> fa-lg
<i class="fa fa-camera-retro fa-2x"></i> fa-2x
<i class="fa fa-close fa-3x"></i> fa-3x
<i class="fa fa-info fa-4x"></i> fa-4x
<i class="fa fa-camera-retro fa-5x"></i> fa-5x
[Edit] the icon size is not equal height/width.
So I changed the answer and added height: 1em; width: 1em; text-align: center;
Just use this:
<i class="fa fa-times-circle"></i>
or if you want you can try this too:
i.custom {
display: inline-block;
background: gray;
color: white;
border-radius: 50%;
}
i.custom:before,
i.custom:after {
display: inline-block;
vertical-align: middle;
height: 40px;
width: 40px;
line-height: 40px;
text-align: center;
}
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
<i class="custom fa fa-close"></i>
<i class="fa fa-times-circle"></i>
I have posts list with thumbnails.
I'm trying to prevent the title from going under the image.
I tried white-space: normal but it didn't effect the text here. I also tried float: left and Display:inline nothing helped to keep the title beside the image.
CODE CSS&HTML:
ul{
list-style-type:none;
padding:0;
background-color:white;
}
li{
border: 1px solid gray;
width: 325px;
border-bottom:1px solid #border-color;
padding:10px;
white-space: normal;
}
img{
width:80px;
height:80px;
}
.post-title{
display: inline-block;
margin-left:5px;
vertical-align: middle;
}
.post-title a{
white-space: normal;
color:#breadcrumbs-current-color;
}
.post-title p{
margin-bottom:0;
color:gray;
font-size:11px;
}
<ul>
<li>
<a><img src="http://blog.room34.com/wp-content/uploads/underdog/logo.thumbnail.png"/ ></a>
<div class="post-title">
<a>Street Dance Moves Comically Illustrated
<p>200 view</p>
</a>
</div>
</li>
<li>
<a><img src="http://www.ionnic.com/media/catalog/product/cache/1/thumbnail/80x80/9df78eab33525d08d6e5fb8d27136e95/b/e/becable.png"/></a>
<div class="post-title">
<a>Hello World
<p>80 view</p>
</a>
</div>
</li>
</ul>
One quick solution is to use max-width and remove vertical-align:
ul {
list-style-type: none;
padding: 0;
background-color: white;
}
li {
border: 1px solid gray;
width: 325px;
border-bottom: 1px solid#border-color;
padding: 10px;
white-space: normal;
}
img {
width: 80px;
height: 80px;
}
.post-title {
display: inline-block;
margin-left: 5px;
max-width: 200px;
}
.post-title a {
white-space: normal;
color: #breadcrumbs-current-color;
}
.post-title p {
margin-bottom: 0;
color: gray;
font-size: 11px;
}
<ul>
<li>
<a>
<img src="http://blog.room34.com/wp-content/uploads/underdog/logo.thumbnail.png" />
</a>
<div class="post-title">
<a>Street Dance Moves Comically Illustrated
<p>200 view</p>
</a>
</div>
</li>
<li>
<a>
<img src="http://www.ionnic.com/media/catalog/product/cache/1/thumbnail/80x80/9df78eab33525d08d6e5fb8d27136e95/b/e/becable.png" />
</a>
<div class="post-title">
<a>Hello World
<p>80 view</p>
</a>
</div>
</li>
</ul>
But i suggest to go with display: table technique:
ul {
list-style-type: none;
padding: 0;
background-color: white;
}
li {
display: table;
border: 1px solid gray;
width: 325px;
border-bottom: 1px solid#border-color;
padding: 10px;
white-space: normal;
}
img {
width: 80px;
height: 80px;
}
.post-title {
display: table-cell;
margin-left: 5px;
max-width: 200px;
vertical-align: middle;
}
.post-title a {
white-space: normal;
color: #breadcrumbs-current-color;
}
.post-title p {
margin-bottom: 0;
color: gray;
font-size: 11px;
}
li > a {
width: 90px;
display: table-cell;
vertical-align: middle;
}
<ul>
<li>
<a>
<img src="http://blog.room34.com/wp-content/uploads/underdog/logo.thumbnail.png" />
</a>
<div class="post-title">
<a>Street Dance Moves Comically Illustrated
<p>200 view</p>
</a>
</div>
</li>
<li>
<a>
<img src="http://www.ionnic.com/media/catalog/product/cache/1/thumbnail/80x80/9df78eab33525d08d6e5fb8d27136e95/b/e/becable.png" />
</a>
<div class="post-title">
<a>Hello World
<p>80 view</p>
</a>
</div>
</li>
<li>
<a>
<img src="http://www.ionnic.com/media/catalog/product/cache/1/thumbnail/80x80/9df78eab33525d08d6e5fb8d27136e95/b/e/becable.png" />
</a>
<div class="post-title">
<a>Hello World Hello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello World
<p>80 view</p>
</a>
</div>
</li>
</ul>
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%;
}