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>
Related
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 want a tooltip above some left-floated elements. I want some of the toolips left-aligned to the left margin of their sibling and some of the right-aligned to the right margin of their tooltips. I can't figure out how to get the elements to right align relative to the left floated sibling.
Below is the code I've tried. I've tried to get the tooltips on the green and blue segments to align to the right of the coloured segments rather than the left but it doesn't work.
.textContent {
margin: 5px 0;
}
.bar {
box-sizing: border-box;
cursor: default;
height: 10px;
overflow: visible;
width: 100%;
}
.segment {
cursor: pointer;
display: inline-block;
float: left;
height: inherit;
position: relative;
width: 20%;
}
.section1 {
background-color: red;
}
.section2 {
background-color: orange;
}
.section3 {
background-color: yellow;
}
.section4 {
background-color: green;
}
.section5 {
background-color: blue;
}
.segment .tooltip {
background-color: #ffffff;
border: 1px solid #cc0000;
border-radius: 5px;
color: #000000;
float: left;
margin-top: 15px;
padding: 5px;
position: absolute;
text-align: center;
visibility: hidden;
z-index: 1;
}
.alignRightTooltip {
float: right;
}
.segment:hover .tooltip {
visibility: visible;
}
<DIV class="textContent">
Hover over bar to display tooltips
</DIV>
<DIV class="textContent">
The tooltips on the <SPAN style="color: green; font-weight: bold">green</SPAN> and <SPAN style="color: blue; font-weight: bold">blue</SPAN> bars should align to the right hand side of the segments
</DIV>
<DIV class="bar">
<DIV class="segment section1">
<SPAN class="tooltip">
section1
</SPAN>
</DIV>
<DIV class="segment section2">
<SPAN class="tooltip">
section2
</SPAN>
</DIV>
<DIV class="segment section3">
<SPAN class="tooltip">
section3
</SPAN>
</DIV>
<DIV class="segment section4">
<SPAN class="tooltip alignRightTooltip">
section4
</SPAN>
</DIV>
<DIV class="segment section5">
<SPAN class="tooltip alignRightTooltip">
section5
</SPAN>
</DIV>
</DIV>
I'd appreciate any feedback, unsure what I'm doing wrong.
Thanks!
Plz try this code.. If you want right alignment for tooltip, plz add "right-align" class..
HTML
<DIV class="segment section4 right-align">
<SPAN class="tooltip alignRightTooltip">
section4
</SPAN>
</DIV>
<DIV class="segment section5 right-align">
<SPAN class="tooltip alignRightTooltip">
section5
</SPAN>
</DIV>
CSS
.segment.right-align span {
right: 0;
}
Add the below css to your code to align the tooltips to the right side
.segment.section4 .tooltip, .segment.section5 .tooltip {
right: 0;
}
Working Demo
.textContent {
margin: 5px 0;
}
.bar {
box-sizing: border-box;
cursor: default;
height: 10px;
overflow: visible;
width: 100%;
}
.segment {
cursor: pointer;
display: inline-block;
float: left;
height: inherit;
position: relative;
width: 20%;
}
.section1 {
background-color: red;
}
.section2 {
background-color: orange;
}
.section3 {
background-color: yellow;
}
.section4 {
background-color: green;
}
.section5 {
background-color: blue;
}
.segment .tooltip {
background-color: #ffffff;
border: 1px solid #cc0000;
border-radius: 5px;
color: #000000;
float: left;
margin-top: 15px;
padding: 5px;
position: absolute;
text-align: center;
visibility: hidden;
z-index: 1;
}
.alignRightTooltip {
float: right;
}
.segment:hover .tooltip {
visibility: visible;
}
.segment.section4 .tooltip,
.segment.section5 .tooltip {
right: 0;
}
<DIV class="textContent">
Hover over bar to display tooltips
</DIV>
<DIV class="textContent">
The tooltips on the
<SPAN style="color: green; font-weight: bold">green</SPAN> and
<SPAN style="color: blue; font-weight: bold">blue</SPAN> bars should align to the right hand side of the segments
</DIV>
<DIV class="bar">
<DIV class="segment section1">
<SPAN class="tooltip">
section1
</SPAN>
</DIV>
<DIV class="segment section2">
<SPAN class="tooltip">
section2
</SPAN>
</DIV>
<DIV class="segment section3">
<SPAN class="tooltip">
section3
</SPAN>
</DIV>
<DIV class="segment section4">
<SPAN class="tooltip alignRightTooltip">
section4
</SPAN>
</DIV>
<DIV class="segment section5">
<SPAN class="tooltip alignRightTooltip">
section5
</SPAN>
</DIV>
</DIV>
Please check if this is what you were expecting and mark this as right answer if this solves your purpose
.textContent {
margin: 5px 0;
}
.bar {
box-sizing: border-box;
cursor: default;
height: 10px;
overflow: visible;
width: 100%;
}
.segment {
cursor: pointer;
display: inline-block;
float: left;
height: inherit;
position: relative;
width: 20%;
}
.section1 {
background-color: red;
}
.section2 {
background-color: orange;
}
.section3 {
background-color: yellow;
}
.section4 {
background-color: green;
}
.section5 {
background-color: blue;
}
.segment .tooltip {
background-color: #ffffff;
border: 1px solid #cc0000;
border-radius: 5px;
color: #000000;
margin-top: 15px;
padding: 5px;
position: relative;
text-align: center;
visibility: hidden;
z-index: 1;
}
.segment:hover .tooltip {
visibility: visible;
float:right;
}
.segment:hover .tooltipLeft {
visibility: visible;
float:left !important;
}
<DIV class="textContent">
Hover over bar to display tooltips
</DIV>
<DIV class="textContent">
The tooltips on the <SPAN style="color: green; font-weight: bold">green</SPAN> and <SPAN style="color: blue; font-weight: bold">blue</SPAN> bars should align to the right hand side of the segments
</DIV>
<DIV class="bar">
<DIV class="segment section1">
<SPAN class="tooltip tooltipLeft ">
section1
</SPAN>
</DIV>
<DIV class="segment section2">
<SPAN class="tooltip tooltipLeft ">
section2
</SPAN>
</DIV>
<DIV class="segment section3">
<SPAN class="tooltip tooltipLeft ">
section3
</SPAN>
</DIV>
<DIV class="segment section4">
<SPAN class="tooltip">
section4
</SPAN>
</DIV>
<DIV class="segment section5">
<SPAN class="tooltip">
section5
</SPAN>
</DIV>
</DIV>
I've been following a tutorial to create mobile navigation without Javascript and the idea behind this is to use a checkbox and the :checked CSS selector. I managed to get it working when I tested it out on a blank page but then when I tried to integrate it into my actual site it stopped working. I'll show the code for both so you can see where perhaps I've gone wrong (note that DIV IDs and classes have changed between the two documents but I've made sure the HTML has also changed accordingly so that's not the problem).
.show-menu {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-decoration: none;
color: black;
background: #ac3333;
text-align: center;
padding: 10px 10px;
border: 1px black solid;
}
#menu {
display: none;
}
/*Hide checkbox*/
input[type=checkbox]{
display: none;
}
/*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ #menu{
display: block;
}
#hamburger {
display: inline-block;
}
.icon-bar {
display: block;
width: 22px;
height: 2px;
border-radius: 1px;
margin-bottom: 4px;
background-color: black;
}
That's the working code. Here's the non-working code. In the non-working code, clicking the button does not do anything and I can't work out why!
body {
margin: 0;
line-height: 1.428;
}
.wrap {
width: 90%;
max-width: 71.5em;
margin: 0 auto;
padding: 0.625em 0.625em;
}
#header {
background: #442869;
padding-top: 1em;
padding-bottom: 1em;
min-height: 6em;
}
#mobile-navigation-btn {
display: none;
}
#mobile-nav {
display: none;
}
#regular-nav {
display: block;
}
.show-menu {
text-decoration: none;
color: black;
background: #ac3333;
text-align: center;
padding: 10px 10px;
border: 1px black solid;
}
/*Hide checkbox*/
input[type=checkbox] {
display: none;
}
/*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ #mobile-nav {
display: block;
}
#hamburger {
display: inline-block;
}
.icon-bar {
display: block;
width: 22px;
height: 2px;
border-radius: 1px;
margin-bottom: 4px;
background-color: black;
}
#media only screen and (max-width: 768px) {
#mobile-navigation-btn {
display: block;
}
#regular-nav {
display: none;
}
}
<div id="header">
<div class="wrap">
<picture>
<source srcset="seiri-logo-regular.png" media="(min-width: 1000px)">
<img srcset="seiri-logo-small.png" alt="…">
</picture>
<div id="mobile-navigation-btn">
<label for="show-menu" class="show-menu">Menu
<div id="hamburger">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</div>
</label>
<input type="checkbox" id="show-menu" role="button">
</div>
<div id="regular-nav">
<ul>
<li>Home
</li>
<li>Customer Research
</li>
<li>Business Improvement
</li>
<li>Contact Us
</li>
<li>Blog
</li>
</ul>
</div>
</div>
</div>
<div id="mobile-nav">
<ul>
<li>Home
</li>
<li>Customer Research
</li>
<li>Business Improvement
</li>
<li>Contact Us
</li>
<li>Blog
</li>
</ul>
</div>
Its not working because of your css selector, the input and the menu need to be siblings the way you currently have the css set. Read this post to understand further the ~ operator
What does the "~" (tilde/squiggle/twiddle) CSS selector mean?
body {
margin: 0;
line-height: 1.428;
}
.wrap {
width: 90%;
max-width: 71.5em;
margin: 0 auto;
padding: 0.625em 0.625em;
}
#header {
background: #442869;
padding-top: 1em;
padding-bottom: 1em;
min-height: 6em;
}
#mobile-navigation-btn {
<!--display: none;
-->
}
#mobile-nav {
display: none;
}
.show-menu {
text-decoration: none;
color: black;
background: #ac3333;
text-align: center;
padding: 10px 10px;
border: 1px black solid;
}
/*Hide checkbox*/
input[type=checkbox] {
<!--display: none;
-->
}
/*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ #mobile-nav {
display: block;
}
#hamburger {
display: inline-block;
}
.icon-bar {
display: block;
width: 22px;
height: 2px;
border-radius: 1px;
margin-bottom: 4px;
background-color: black;
}
#media only screen and (max-width: 768px) {
#mobile-navigation-btn {
display: block;
}
#regular-nav {
display: none;
}
}
<!doctype html>
<head>
<script>
// Picture element HTML5 shiv
document.createElement("picture");
</script>
<script src="picturefill.min.js" async></script>
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="header">
<div class="wrap">
<picture>
<source srcset="seiri-logo-regular.png" media="(min-width: 1000px)">
<img srcset="seiri-logo-small.png" alt="…">
</picture>
<div id="mobile-navigation-btn">
<label for="show-menu" class="show-menu">Menu
<div id="hamburger">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</div>
</label>
</div>
</div>
</div>
<input type="checkbox" id="show-menu" role="button" />
<div id="mobile-nav">
<ul>
<li>Home
</li>
<li>Customer Research
</li>
<li>Business Improvement
</li>
<li>Contact Us
</li>
<li>Blog
</li>
</ul>
</div>
</body>
</html>
I've been stuck on this for a while. Please see image attached. I need to make a circle with a centered letter inside it and a line to text aligned centre to the circle. I need help with rest of the code.
.lettercircle {
font-family: Helvetica, sans-serif;
background-color: #009cda;
color: #fff;
padding: 5px 12px;
border-radius: 50%;
font-size: 28px;
}
#div {
width: 499px;
height: 166px;
}
<div id="div">
<ul>
<li> <span>A</span>
DREAMWEAVER
</li>
<li> <span>B</span>
PHOTOSHOP
</li>
</ul>
</div>
How about this:
.lettercircle {
font-family: Helvetica, sans-serif;
background-color: #333;
color: #fff;
padding: 5px 9px;
border-radius: 50%;
font-size: 12px;
display: table-cell;
vertical-align: middle;
}
.title {
padding-left: 10px;
display: table-cell;
vertical-align: middle;
}
#div {
width: 499px;
background: red;
height: 100%;
padding: 10px;
}
#div > ul {
padding: 0;
display: table-cell;
vertical-align: middle;
}
#div > ul > li {
list-style: none;
padding: 10px;
font-family: Helvetica, sans-serif;
text-transform: uppercase;
display: table;
}
<div id="div">
<ul>
<li>
<span class="lettercircle">A</span>
<span class="title">DREAMWEAVER</span>
</li>
<li>
<span class="lettercircle">B</span>
<span class="title">PHOTOSHOP</span>
</li>
</ul>
</div>
I think you just forgot to add your class to your spans.
.lettercircle {
font-family: Helvetica, sans-serif;
background-color: #009cda;
color: #fff;
padding: 5px 12px;
border-radius: 50%;
font-size: 28px;
}
#div {
width: 499px;
height: 166px;
}
<div id="div">
<ul>
<li> <span class="lettercircle">A</span>
DREAMWEAVER
</li>
<li> <span class="lettercircle">B</span>
PHOTOSHOP
</li>
</ul>
</div>
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%;
}