I'm having a bit of trouble having my text display only within my image. It's dependent on the length of the text, if it's two rows long, then it'll display correct. Any longer it'll extend past the image. I can fix this by setting the bottom: 25px; for my featured_wrapper but I don't think that's a Good fix. If the text is only 2 rows long then that it sets the text higher than it should. May I ask how should I properly set the text so that it'll always remain within the image.
<div id="featured_item">
<a href="http://bandwagonbible.com/Fitness/GettingSixPackAbs" id="featured_link">
<picture id="featured_picture">
<img src="http://bandwagonbible.com/Stories/Fitness/GettingSixPackAbs/Image2.jpg" id="featured_image" alt='' />
</picture>
<div id="featured_wrapper">
<h3 id="featured_title">
A Beginners Guide To Getting Six Pack Abs ... add in some more text
</h3>
</div>
</a>
</div>
http://codepen.io/anon/pen/eZVdpq
Change the height to auto in your #featured_wrapper rule
#featured_wrapper {
bottom: -2px;
box-sizing: border-box;
color: rgb(40, 173, 230);
height: auto; /* <--- changed to auto */
#featured_item {
box-sizing: border-box;
color: rgb(34, 34, 34);
height: 173.813px;
min-height: auto;
min-width: auto;
overflow-wrap: break-word;
position: relative;
width: 309.297px;
word-wrap: break-word;
perspective-origin: 154.641px 86.9063px;
transform-origin: 154.641px 86.9063px;
border: 0px none rgb(34, 34, 34);
font: normal normal normal normal 16px / 24px ProximaNovaCond, sans-serif;
margin: 0px 21px 0px 0px;
outline: rgb(34, 34, 34) none 0px;
}
#featured_link {
box-sizing: border-box;
color: rgb(40, 173, 230);
display: block;
height: 173.813px;
overflow-wrap: break-word;
text-decoration: none;
width: 309.297px;
word-wrap: break-word;
perspective-origin: 154.641px 86.9063px;
transform-origin: 154.641px 86.9063px;
background: rgb(245, 245, 245) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(40, 173, 230);
font: normal normal normal normal 16px / 24px ProximaNovaCond, sans-serif;
outline: rgb(40, 173, 230) none 0px;
padding: 0px 0px 173.813px;
}
#featured_picture {
box-sizing: border-box;
color: rgb(40, 173, 230);
overflow-wrap: break-word;
text-rendering: optimizeLegibility;
word-wrap: break-word;
border: 0px none rgb(40, 173, 230);
font: normal normal normal normal 16px / 24px ProximaNovaCond, sans-serif;
outline: rgb(40, 173, 230) none 0px;
}
#featured_image {
box-sizing: border-box;
color: rgb(40, 173, 230);
display: inline-block;
height: 173.969px;
max-width: 100%;
overflow-wrap: break-word;
text-rendering: optimizeLegibility;
vertical-align: middle;
width: 309.297px;
word-wrap: break-word;
perspective-origin: 154.641px 86.9844px;
transform-origin: 154.641px 86.9844px;
background: rgb(245, 245, 245) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(40, 173, 230);
font: normal normal normal normal 16px / 24px ProximaNovaCond, sans-serif;
outline: rgb(40, 173, 230) none 0px;
overflow: hidden;
}
#featured_wrapper {
bottom: -2px;
box-sizing: border-box;
color: rgb(40, 173, 230);
height: auto;
left: 0px;
overflow-wrap: break-word;
position: absolute;
right: 20px;
width: 289.297px;
word-wrap: break-word;
perspective-origin: 144.641px 45px;
transform-origin: 104.641px 45px;
border: 0px none rgb(40, 173, 230);
font: normal normal normal normal 16px / 24px ProximaNovaCond, sans-serif;
outline: rgb(40, 173, 230) none 0px;
}
#featured_title {
box-sizing: border-box;
color: rgb(255, 255, 255);
display: inline;
height: auto;
overflow-wrap: break-word;
position: relative;
text-rendering: optimizeLegibility;
width: auto;
word-wrap: break-word;
background: rgba(0, 0, 0, 0.701961) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(255, 255, 255);
font: normal normal normal normal 22px / 22px ProximaNovaCond, sans-serif;
margin: 0px 0px 0px;
outline: rgb(255, 255, 255) none 0px;
padding: 0px 10px;
transition: all 0.1s ease-in-out 0s;
}
<div id="featured_item">
<a href="http://bandwagonbible.com/Fitness/GettingSixPackAbs" id="featured_link">
<picture id="featured_picture">
<img src="http://bandwagonbible.com/Stories/Fitness/GettingSixPackAbs/Image2.jpg" id="featured_image" alt='' />
</picture>
<div id="featured_wrapper">
<h3 id="featured_title">
A Beginners Guide To Getting Six Pack Abs ... add in some more text
</h3>
</div>
</a>
</div>
And I don't think you need all that CSS/markup either, so here is a shortened version for you.
#featured_item {
position: relative;
width: 309.297px;
margin: 0px 21px 0px 0px;
}
#featured_link {
display: block;
position: relative;
text-decoration: none;
}
#featured_image {
max-width: 100%;
}
#featured_title {
color: rgb(255, 255, 255);
height: auto;
position: absolute;
left: 0;
right: 0;
bottom: 0;
text-rendering: optimizeLegibility;
background: rgba(0, 0, 0, 0.701961);
font: normal 22px / 22px ProximaNovaCond, sans-serif;
padding: 0px 10px;
transition: all 0.1s ease-in-out 0s;
}
<div id="featured_item">
<a href="http://bandwagonbible.com/Fitness/GettingSixPackAbs" id="featured_link">
<img src="http://bandwagonbible.com/Stories/Fitness/GettingSixPackAbs/Image2.jpg" id="featured_image" alt='' />
<div id="featured_title">
A Beginners Guide To Getting Six Pack Abs ... add in some more text
</div>
</a>
</div>
Remove the height: 50px; in the #featured_wrapper rule and also change the bottom:2px; to 0 to make it be stick to the bottom.
Like this
I also change the display:inline of the text and add a width:100% to make the text adapt the full width of the image.
Related
This question already has answers here:
CSS - Equal Height Columns?
(11 answers)
Closed 6 years ago.
#DIV_1 {
bottom: -10px;
height: 176px;
left: 0px;
position: relative;
right: 0px;
text-align: left;
top: 10px;
width: 379px;
perspective-origin: 189.5px 88px;
transform-origin: 189.5px 88px;
background: rgb(238, 238, 238) none repeat scroll 0% 0% / auto padding-box border-box;
font: normal normal normal normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif;
list-style: none outside none;
margin: 0px 0px -5px;
overflow: hidden;
}/*#DIV_1*/
#DIV_2 {
box-sizing: border-box;
float: left;
height: 77px;
text-align: center;
width: 189.5px;
perspective-origin: 94.75px 38.5px;
transform-origin: 94.75px 38.5px;
border-right: 5px solid rgb(255, 255, 255);
font: normal normal normal normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif;
list-style: none outside none;
padding: 30px;
}/*#DIV_2*/
#DIV_3 {
box-sizing: border-box;
float: left;
height: 77px;
text-align: center;
width: 189.5px;
perspective-origin: 94.75px 38.5px;
transform-origin: 94.75px 38.5px;
font: normal normal normal normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif;
list-style: none outside none;
padding: 30px;
}/*#DIV_3*/
#DIV_4 {
box-sizing: border-box;
color: rgb(255, 255, 255);
float: left;
height: 99px;
text-align: center;
width: 189.5px;
column-rule-color: rgb(255, 255, 255);
perspective-origin: 94.75px 49.5px;
transform-origin: 94.75px 49.5px;
background: rgb(192, 57, 43) none repeat scroll 0% 0% / auto padding-box border-box;
border-top: 5px solid rgb(255, 255, 255);
border-right: 5px solid rgb(255, 255, 255);
border-bottom: 0px none rgb(255, 255, 255);
border-left: 0px none rgb(255, 255, 255);
font: normal normal bold normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif;
list-style: none outside none;
outline: rgb(255, 255, 255) none 0px;
padding: 30px;
}/*#DIV_4*/
#DIV_5 {
box-sizing: border-box;
color: rgb(255, 255, 255);
float: left;
height: 82px;
text-align: center;
width: 189.5px;
column-rule-color: rgb(255, 255, 255);
perspective-origin: 94.75px 41px;
transform-origin: 94.75px 41px;
background: rgb(142, 68, 173) none repeat scroll 0% 0% / auto padding-box border-box;
border-top: 5px solid rgb(255, 255, 255);
border-right: 0px none rgb(255, 255, 255);
border-bottom: 0px none rgb(255, 255, 255);
border-left: 0px none rgb(255, 255, 255);
font: normal normal bold normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif;
list-style: none outside none;
outline: rgb(255, 255, 255) none 0px;
padding: 30px;
}/*#DIV_5*/
<div id="DIV_1">
<div id="DIV_2">
Ben Franklin
</div>
<div id="DIV_3">
Thomas Jefferson
</div>
<div id="DIV_4">
George Washington
</div>
<div id="DIV_5">
Abraham Lincoln
</div>
</div>
I have 2 column that its content might have different length, thus it will have multiple lines, so how do I ensure that the least line of content have the equal height? I can't use fixed height like height:100px; because the length of the content might be more than that.
You can use flexbox to achieve equal heights. This is set on the outer wrapper div:
#DIV_1 {
display: flex;
flex-wrap: wrap;
}
You'll also need to remove the fixed heights and float on the inner divs. If you also want the content in the inner divs to be vertically centered you can make then display:
#DIV_2,
#DIV_3,
#DIV_4,
#DIV_5 {
display: flex;
flex-direction: column;
justify-content: center;
}
#DIV_1 {
bottom: -10px;
display: flex;
flex-wrap: wrap;
left: 0px;
position: relative;
right: 0px;
text-align: left;
top: 10px;
width: 379px;
perspective-origin: 189.5px 88px;
transform-origin: 189.5px 88px;
background: rgb(238, 238, 238) none repeat scroll 0% 0% / auto padding-box border-box;
font: normal normal normal normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif;
list-style: none outside none;
margin: 0px 0px -5px;
overflow: hidden;
}/*#DIV_1*/
#DIV_2 {
box-sizing: border-box;
text-align: center;
width: 189.5px;
perspective-origin: 94.75px 38.5px;
transform-origin: 94.75px 38.5px;
border-right: 5px solid rgb(255, 255, 255);
font: normal normal normal normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif;
list-style: none outside none;
padding: 30px;
}/*#DIV_2*/
#DIV_3 {
box-sizing: border-box;
text-align: center;
width: 189.5px;
perspective-origin: 94.75px 38.5px;
transform-origin: 94.75px 38.5px;
font: normal normal normal normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif;
list-style: none outside none;
padding: 30px;
}/*#DIV_3*/
#DIV_4 {
box-sizing: border-box;
color: rgb(255, 255, 255);
text-align: center;
width: 189.5px;
column-rule-color: rgb(255, 255, 255);
perspective-origin: 94.75px 49.5px;
transform-origin: 94.75px 49.5px;
background: rgb(192, 57, 43) none repeat scroll 0% 0% / auto padding-box border-box;
border-top: 5px solid rgb(255, 255, 255);
border-right: 5px solid rgb(255, 255, 255);
border-bottom: 0px none rgb(255, 255, 255);
border-left: 0px none rgb(255, 255, 255);
font: normal normal bold normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif;
list-style: none outside none;
outline: rgb(255, 255, 255) none 0px;
padding: 30px;
}/*#DIV_4*/
#DIV_5 {
box-sizing: border-box;
color: rgb(255, 255, 255);
text-align: center;
width: 189.5px;
column-rule-color: rgb(255, 255, 255);
perspective-origin: 94.75px 41px;
transform-origin: 94.75px 41px;
background: rgb(142, 68, 173) none repeat scroll 0% 0% / auto padding-box border-box;
border-top: 5px solid rgb(255, 255, 255);
border-right: 0px none rgb(255, 255, 255);
border-bottom: 0px none rgb(255, 255, 255);
border-left: 0px none rgb(255, 255, 255);
font: normal normal bold normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif;
list-style: none outside none;
outline: rgb(255, 255, 255) none 0px;
padding: 30px;
}/*#DIV_5*/
<div id="DIV_1">
<div id="DIV_2">
Ben Franklin
</div>
<div id="DIV_3">
Thomas Jefferson
</div>
<div id="DIV_4">
George Washington
</div>
<div id="DIV_5">
Abraham Lincoln
</div>
</div>
I have a button created with css on a web application, when I test the button on chrome on android the button renders fine and stays on top of everything because of the z-index property:
But when I test the same thing on chrome on IOS it doesnt renders the button the way its supposed to be and doesnt respect the z-index property:
I tried to add "-webkit-appearance: none;" to the css but it didnt worked heres the css and html:
#PINPOINT {
-webkit-appearance: none;
width: 70px;
height: 70px;
margin: 15px auto;
position: relative;
z-index: 5000;
}
#BUTTON {
-webkit-appearance: none;
box-sizing: border-box;
color: rgba(0, 0, 0, 0.870588);
height: 70px;
text-align: left;
width: 70px;
column-rule-color: rgba(0, 0, 0, 0.870588);
perspective-origin: 227.828px 35px;
transform-origin: 227.828px 35px;
border: 0px none rgba(0, 0, 0, 0.870588);
font: normal normal normal normal 14px / 21px Roboto, sans-serif;
outline: rgba(0, 0, 0, 0.870588) none 0px;
position: fixed;
right: 0;
}
#TEXT {
-webkit-appearance: none;
bottom: 0px;
box-shadow: rgba(0, 0, 0, 0.156863) 0px 2px 5px 0px, rgba(0, 0, 0, 0.117647) 0px 2px 10px 0px;
box-sizing: border-box;
color: rgb(255, 255, 255);
cursor: pointer;
display: inline-block;
height: 55.5px;
left: 0px;
letter-spacing: 0.5px;
position: relative;
right: 0px;
text-align: center;
text-decoration: none;
text-transform: uppercase;
top: 0px;
vertical-align: middle;
width: 55.5px;
will-change: opacity, transform;
z-index: 1;
column-rule-color: rgb(255, 255, 255);
perspective-origin: 27.75px 27.75px;
transform-origin: 27.75px 27.75px;
background: rgb(239, 83, 80) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(255, 255, 255);
border-radius: 50% 50% 50% 50%;
font: normal normal normal normal 14px / 56px Roboto, sans-serif;
margin: 0px 0px 14px;
outline: rgb(255, 255, 255) none 0px;
overflow: hidden;
transition: all 0.3s ease-out 0s;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<div id="PINPOINT">
<div id="BUTTON">
<i class="fa fa-reply" aria-hidden="true"></i>
</div>
</div>
You may use flexbox to make them align horizontally and vertically center. Here's the code.
#PINPOINT {
-webkit-appearance: none;
width: 70px;
height: 70px;
margin: 15px auto;
position: relative;
z-index: 5000;
}
#BUTTON {
-webkit-appearance: none;
box-sizing: border-box;
color: rgba(0, 0, 0, 0.870588);
height: 70px;
text-align: left;
width: 70px;
column-rule-color: rgba(0, 0, 0, 0.870588);
perspective-origin: 227.828px 35px;
transform-origin: 227.828px 35px;
border: 0px none rgba(0, 0, 0, 0.870588);
font: normal normal normal normal 14px / 21px Roboto, sans-serif;
outline: rgba(0, 0, 0, 0.870588) none 0px;
position: fixed;
right: 0;
}
#TEXT {
-webkit-appearance: none;
box-shadow: rgba(0, 0, 0, 0.156863) 0px 2px 5px 0px, rgba(0, 0, 0, 0.117647) 0px 2px 10px 0px;
box-sizing: border-box;
color: rgb(255, 255, 255);
cursor: pointer;
height: 55.5px;
letter-spacing: 0.5px;
position: relative;
text-align: center;
text-decoration: none;
text-transform: uppercase;
vertical-align: middle;
width: 55.5px;
will-change: opacity, transform;
z-index: 1;
transform-origin: 27.75px 27.75px;
background: rgb(239, 83, 80) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(255, 255, 255);
border-radius: 50% 50% 50% 50%;
font: normal normal normal normal 14px / 56px Roboto, sans-serif;
margin: 0px 0px 14px;
outline: rgb(255, 255, 255) none 0px;
overflow: hidden;
transition: all 0.3s ease-out 0s;
/*Use flexbox property to fix this.*/
display: flex;
justify-content: center;
align-items:center;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
<div id="PINPOINT">
<div id="BUTTON">
<i class="fa fa-reply" aria-hidden="true"></i>
</div>
</div>
I'm having trouble fitting any amount of content inside the entire block div, I've tried to set the height to auto however that didn't work, I've tried the overflow property which didn't work as well. I would like the entire div height to expand when there is more content because I'm dynamically changing the content, I'm not understanding why the entire div height is not expanding as there is more content inside it. Below is the example.
Please provide thorough explanation to why the div height is not expanding.
#entire-block {
bottom: 50px;
box-shadow: rgb(159, 159, 155) 4px 4px 4px -1px;
box-sizing: border-box;
/* min-height: 136px; */
height: auto;
position: fixed;
overflow: ;
right: 0px;
width: 370px;
z-index: 999;
background: rgb(215, 215, 210) none repeat scroll 0% 0% / auto padding-box border-box;
font: normal normal normal 16px/16px'Times New Roman';
padding: 10px 10px 13px;
}
/*#DIV_1*/
#A_2 {
box-sizing: border-box;
color: rgb(255, 255, 255);
cursor: pointer;
display: none;
left: 5px;
position: fixed;
text-decoration: none solid rgb(255, 255, 255);
top: 43px;
z-index: 999;
border: 0px none rgb(255, 255, 255);
font: normal normal normal 25px/25px'Source Sans Pro ExtraLight';
outline: rgb(255, 255, 255) none 0px;
}
/*#A_2*/
#x {
box-sizing: border-box;
color: rgb(255, 255, 255);
cursor: pointer;
display: block;
float: right;
height: 44px;
text-decoration: none solid rgb(255, 255, 255);
width: 21px;
border: 0px none rgb(255, 255, 255);
font: normal normal normal 44px/44px'Source Sans Pro ExtraLight';
margin: -11px 0px 0px;
outline: rgb(255, 255, 255) none 0px;
}
/*#A_3*/
#entire-content-section {
box-sizing: border-box;
height: 113px;
width: 350px;
font: normal normal normal 16px/16px'Times New Roman';
}
/*#DIV_4*/
#IMG_5 {
box-sizing: border-box;
display: block;
float: left;
height: auto;
width: 40px;
font: normal normal normal 16px/16px'Times New Roman';
margin: 0px 10px 0px 0px;
}
/*#IMG_5*/
#top-content-section {
box-sizing: border-box;
height: 90px;
width: 350px;
font: normal normal normal 16px/16px'Times New Roman';
}
/*#DIV_6*/
#content-header {
box-sizing: border-box;
height: 56px;
width: 350px;
font: normal normal normal 28px/28px league_gothicregular;
margin: 0px;
padding-top: 1%;
}
/*#H3_7*/
#middle-content {
box-sizing: border-box;
font: normal normal normal 16px/16px'Source Sans Pro';
}
/*#SPAN_8*/
#content-bottom {
box-sizing: border-box;
color: rgb(0, 173, 237);
cursor: pointer;
display: block;
height: 12px;
letter-spacing: 1.6799999475479126px;
text-decoration: none solid rgb(0, 173, 237);
text-transform: uppercase;
width: 350px;
border: 0px none rgb(0, 173, 237);
font: normal normal normal 12px/12px'Source Sans Pro Black';
margin: 11px 0px 0px;
outline: rgb(0, 173, 237) none 0px;
}
/*#A_11*/
<div id="entire-block">
<a id="x">×</a>
<div id="entire-content-section">
<img src="http://www.ratemyprofessors.com/assets/average-icon-b4b6eb5e309d26486d76ecebe920220f.jpg?1455038037" id="IMG_5" alt='' />
<div id="top-content-section">
<h3 id="content-header">
Average
</h3> <span id="middle-content">Attending class is not necessary, but reading the textbook is a must. I attended all of his classes for ECON1000 but didn't find it helpful, so I never went to class for ECON1010. Do your readings and study from the test banks. With some effort, you're guaranteed to get an A. Would take his class again.</span>
</div>
Find out what students are saying.
</div>
</div>
You have fixed the height that's why it is showing of fixed height. Remove height from #entire-content-section and #top-content-section.
This question already has answers here:
Line before and after title over image [duplicate]
(2 answers)
Closed 7 years ago.
I am trying to draw two horizontal lines across a box:
http://codepen.io/anon/pen/gpZqOQ
I used a plugin to generate some code based on a design. However the end result is not optimized.
<h1 id="H1_1">
<span id="SPAN_2">Feedback</span>
</h1>
#H1_1 {
box-sizing: border-box;
clear: both;
color: rgb(64, 64, 64);
height: 45px;
position: relative;
text-align: center;
width: 1140px;
perspective-origin: 570px 22.5px;
transform-origin: 570px 22.5px;
border: 0px none rgb(64, 64, 64);
font: normal normal normal normal 15px/22.5px 'Source Sans Pro', sans-serif;
margin: 0px 0px 70px;
outline: rgb(64, 64, 64) none 0px;
}/*#H1_1*/
#H1_1:after {
box-sizing: border-box;
color: rgb(64, 64, 64);
display: block;
height: 1px;
left: 0px;
position: absolute;
text-align: center;
top: 22.5px;
width: 1140px;
align-self: stretch;
perspective-origin: 570px 0.5px;
transform-origin: 570px 0.5px;
content: '"' '"';
background: rgb(189, 195, 199) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(64, 64, 64);
font: normal normal normal normal 15px/22.5px 'Source Sans Pro', sans-serif;
outline: rgb(64, 64, 64) none 0px;
}/*#H1_1:after*/
#SPAN_2 {
box-sizing: border-box;
color: rgb(189, 195, 199);
display: inline-block;
height: 45px;
position: relative;
text-align: center;
text-transform: uppercase;
width: 108.890625px;
z-index: 10;
perspective-origin: 54.4375px 22.5px;
transform-origin: 54.4375px 22.5px;
background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box;
border: 3px solid rgb(189, 195, 199);
font: normal normal bold normal 15px/normal Montserrat, sans-serif;
outline: rgb(189, 195, 199) none 0px;
padding: 10px 20px;
transition: all 0.2s ease 0s;
}/*#SPAN_2*/
Is there any other simpler way to achieve this via CSS?
<hr style=" width : 100%;">
<span id="SPAN_2">Feedback</span>
Apply following CSS
hr{
display: inline-block;
margin: 25px 0;
position: absolute;
}
#SPAN_2 {
position: absolute;
z-index: 2;
display: inline-block;
border: 3px solid rgb(189, 195, 199);
outline: rgb(189, 195, 199) none 0px;
padding: 10px 20px;
margin: 0 0 0 50%;
}
Try this:
<div>
bla
</div>
in combination with:
div {
padding: 80px;
background-color: red;
border-top: 5px double black;
border-bottom: 3px dotted black;
}
See http://jsfiddle.net/4ghvvke3/ to get the idea.
Or do I misunderstand your question, and do you wish to have a line behind your main box object?
I that case I advise background-image of 1px width with x-repeat, probably less bytes than all the CSS code.
Demo
using :before and :after like you have it, i added a classname instead of random ids
<h1 class="feedback">
<span>Feedback</span>
</h1>
css
.feedback {
position: relative;
text-align: center;
}
.feedback span {
box-sizing: border-box;
color: rgb(189, 195, 199);
display: inline-block;
height: 45px;
position: relative;
text-align: center;
text-transform: uppercase;
width: auto;
z-index: 10;
perspective-origin: 54.4375px 22.5px;
transform-origin: 54.4375px 22.5px;
background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box;
border: 3px solid rgb(189, 195, 199);
font: normal normal bold normal 15px/normal Montserrat, sans-serif;
outline: rgb(189, 195, 199) none 0px;
padding: 10px 20px;
transition: all 0.2s ease 0s;
position: relative;
z-index: 1;
}
.feedback:before,
.feedback:after {
content: '';
display: inline-block;
border: 1px solid rgb(189, 195, 199);
width: 100%;
position: absolute;
z-index: 0;
left: 0;
}
.feedback:before {
top: 40%;
}
.feedback:after {
bottom: 40%;
}
I made a simple fiddle to demonstrate the simplest way of achieving this.
<div id="box">
<hr class="line1">
<hr class="line2">
</div>
And CSS:
#box {
width: 85%;
margin: 0 auto;
}
.line1 {
width: 100%;
}
.line2 {
width: 100%;
}
This uses the hr property to draw 2 lines horizontally, in this case taking up 100% width of the parent container.
Or something like this for thinner lines.
.container {
width: 100%;
margin-top:3em;
text-align:center;
}
.feedback_box {
color: rgb(189, 195, 199);
line-height:45px;
text-align: center;
text-transform: uppercase;
background: rgb(255, 255, 255);
border: 3px solid rgb(189, 195, 199);
font: normal normal bold normal 15px/normal Montserrat, sans-serif;
padding: 1em;
z-index:4;
position:relative;
}
.line1, .line2 {
border:0;
height:3px;
background:rgb(189, 195, 199);
}
.line1 {
margin-bottom:-20px;
}
.line2 {
margin-top:-20px;
}
<div class="container">
<hr class="line1">
<span class="feedback_box">Feedback</span>
<hr class="line2">
</div>
I'm trying to get li hover effect like the one on the right side bar of this page http://smokefree.gov/health-effects
as you see when you hover the background color and text color change
this is the code :
#ASIDE_1 {
box-sizing: border-box;
color: rgb(51, 51, 51);
float: left;
height: 528.171875px;
min-height: 30px;
width: 298.859375px;
perspective-origin: 149.421875px 264.078125px;
transform-origin: 149.421875px 264.078125px;
background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(51, 51, 51);
font: normal normal normal normal 17px/26.0399990081787px cabinregular, Arial, Helvetica, sans-serif;
margin: 13.4399995803833px 12.015625px 0px 8.3125px;
outline: rgb(51, 51, 51) none 0px;
}/*#ASIDE_1*/
#DIV_2 {
color: rgb(51, 51, 51);
height: 232px;
width: 298.859375px;
perspective-origin: 149.421875px 116px;
transform-origin: 149.421875px 116px;
border: 0px none rgb(51, 51, 51);
font: normal normal normal normal 17px/26.0399990081787px cabinregular, Arial, Helvetica, sans-serif;
outline: rgb(51, 51, 51) none 0px;
}/*#DIV_2*/
#DIV_3 {
color: rgb(51, 51, 51);
height: 232px;
width: 298.859375px;
perspective-origin: 149.421875px 116px;
transform-origin: 149.421875px 116px;
border: 0px none rgb(51, 51, 51);
font: normal normal normal normal 17px/26.0399990081787px cabinregular, Arial, Helvetica, sans-serif;
outline: rgb(51, 51, 51) none 0px;
overflow: hidden;
}/*#DIV_3*/
#IMG_4 {
color: rgb(51, 51, 51);
display: block;
height: 232px;
max-width: 100%;
vertical-align: middle;
width: 298.859375px;
perspective-origin: 149.421875px 116px;
transform-origin: 149.421875px 116px;
border: 0px none rgb(51, 51, 51);
font: normal normal normal normal 17px/26.0399990081787px cabinregular, Arial, Helvetica, sans-serif;
outline: rgb(51, 51, 51) none 0px;
}/*#IMG_4*/
#DIV_5 {
color: rgb(51, 51, 51);
height: 283.171875px;
width: 298.859375px;
perspective-origin: 149.421875px 148.078125px;
transform-origin: 149.421875px 148.078125px;
border-top: 13px solid rgb(240, 240, 240);
border-right: 0px none rgb(51, 51, 51);
border-bottom: 0px none rgb(51, 51, 51);
border-left: 0px none rgb(51, 51, 51);
font: normal normal normal normal 17px/26.0399990081787px cabinregular, Arial, Helvetica, sans-serif;
outline: rgb(51, 51, 51) none 0px;
}/*#DIV_5*/
#UL_6 {
color: rgb(84, 84, 84);
height: 283.171875px;
width: 298.859375px;
perspective-origin: 149.421875px 141.578125px;
transform-origin: 149.421875px 141.578125px;
background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(84, 84, 84);
font: normal normal normal normal 17px/26.0399990081787px cabinregular, Arial, Helvetica, sans-serif;
margin: 0px;
outline: rgb(84, 84, 84) none 0px;
padding: 0px;
}/*#UL_6*/
#LI_7 {
color: rgb(181, 96, 0);
height: 92.390625px;
min-height: 92.3999938964844px;
width: 283.921875px;
perspective-origin: 149.421875px 47.1875px;
transform-origin: 149.421875px 47.1875px;
background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box;
border-top: 0px none rgb(181, 96, 0);
border-right: 0px none rgb(181, 96, 0);
border-bottom: 2px solid rgb(240, 240, 240);
border-left: 0px none rgb(181, 96, 0);
font: normal normal normal normal 17px/20px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
outline: rgb(181, 96, 0) none 0px;
padding: 0px 0px 0px 14.9375px;
}/*#LI_7*/
#A_8, #A_15, #A_22 {
color: rgb(0, 136, 204);
text-align: left;
text-decoration: none;
border: 0px none rgb(0, 136, 204);
font: normal normal normal normal 17px/20px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
outline: rgb(0, 136, 204) none 0px;
}/*#A_8, #A_15, #A_22*/
#DIV_9, #DIV_16, #DIV_23 {
color: rgb(0, 136, 204);
display: inline-block;
height: 73.390625px;
text-align: left;
width: 232.8125px;
perspective-origin: 116.40625px 36.6875px;
transform-origin: 116.40625px 36.6875px;
border: 0px none rgb(0, 136, 204);
font: normal normal normal normal 17px/20px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
outline: rgb(0, 136, 204) none 0px;
}/*#DIV_9, #DIV_16, #DIV_23*/
#H2_10 {
color: rgb(181, 96, 0);
height: 39px;
text-align: left;
text-rendering: optimizelegibility;
width: 220.21875px;
perspective-origin: 110.109375px 19.5px;
transform-origin: 110.109375px 19.5px;
background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(181, 96, 0);
font: normal normal bold normal 25px/39.0599975585938px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
margin: 0px 12.5999994277954px 0px 0px;
outline: rgb(181, 96, 0) none 0px;
}/*#H2_10*/
#P_11, #P_18, #P_25 {
color: rgb(84, 84, 84);
height: 26px;
text-align: left;
width: 232.8125px;
perspective-origin: 116.40625px 13px;
transform-origin: 116.40625px 13px;
border: 0px none rgb(84, 84, 84);
font: normal normal normal normal 17px/26.0399990081787px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
margin: 0px 0px 8.39999961853027px;
outline: rgb(84, 84, 84) none 0px;
}/*#P_11, #P_18, #P_25*/
#DIV_12 {
background-position: 0px 0px;
color: rgb(0, 136, 204);
float: right;
height: 35px;
text-align: left;
width: 28.390625px;
perspective-origin: 14.1875px 17.5px;
transform-origin: 14.1875px 17.5px;
background: rgba(0, 0, 0, 0) url(http://smokefree.gov/sites/all/themes/sfg/images/content/smokefree-content-page-related-link-ong-mobile-43x43.png) no-repeat scroll 0px 0px / 90% padding-box border-box;
border: 0px none rgb(0, 136, 204);
font: normal normal normal normal 17px/20px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
margin: 25px 8.39999961853027px 0px 0px;
outline: rgb(0, 136, 204) none 0px;
}/*#DIV_12*/
#IMG_13, #IMG_20, #IMG_27 {
color: rgb(0, 136, 204);
height: 1px;
max-width: 100%;
text-align: left;
vertical-align: middle;
width: 1px;
perspective-origin: 0.5px 0.5px;
transform-origin: 0.5px 0.5px;
border: 0px none rgb(0, 136, 204);
font: normal normal normal normal 17px/20px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
outline: rgb(0, 136, 204) none 0px;
}/*#IMG_13, #IMG_20, #IMG_27*/
#LI_14 {
color: rgb(0, 128, 171);
height: 92.390625px;
min-height: 92.3999938964844px;
width: 283.921875px;
perspective-origin: 149.421875px 47.1875px;
transform-origin: 149.421875px 47.1875px;
background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box;
border-top: 0px none rgb(0, 128, 171);
border-right: 0px none rgb(0, 128, 171);
border-bottom: 2px solid rgb(240, 240, 240);
border-left: 0px none rgb(0, 128, 171);
font: normal normal normal normal 17px/20px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
outline: rgb(0, 128, 171) none 0px;
padding: 0px 0px 0px 14.9375px;
}/*#LI_14*/
#H2_17 {
color: rgb(0, 128, 171);
height: 39px;
text-align: left;
text-rendering: optimizelegibility;
width: 220.21875px;
perspective-origin: 110.109375px 19.5px;
transform-origin: 110.109375px 19.5px;
background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(0, 128, 171);
font: normal normal bold normal 25px/39.0599975585938px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
margin: 0px 12.5999994277954px 0px 0px;
outline: rgb(0, 128, 171) none 0px;
}/*#H2_17*/
#DIV_19 {
background-position: 0px 0px;
color: rgb(0, 136, 204);
float: right;
height: 35px;
text-align: left;
width: 28.390625px;
perspective-origin: 14.1875px 17.5px;
transform-origin: 14.1875px 17.5px;
background: rgba(0, 0, 0, 0) url(http://smokefree.gov/sites/all/themes/sfg/images/content/smokefree-content-page-related-link-blu-mobile-43x43.png) no-repeat scroll 0px 0px / 90% padding-box border-box;
border: 0px none rgb(0, 136, 204);
font: normal normal normal normal 17px/20px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
margin: 25px 8.39999961853027px 0px 0px;
outline: rgb(0, 136, 204) none 0px;
}/*#DIV_19*/
#LI_21 {
color: rgb(96, 128, 24);
height: 92.390625px;
min-height: 92.3999938964844px;
width: 283.921875px;
perspective-origin: 149.421875px 47.1875px;
transform-origin: 149.421875px 47.1875px;
background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box;
border-top: 0px none rgb(96, 128, 24);
border-right: 0px none rgb(96, 128, 24);
border-bottom: 2px solid rgb(240, 240, 240);
border-left: 0px none rgb(96, 128, 24);
font: normal normal normal normal 17px/20px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
outline: rgb(96, 128, 24) none 0px;
padding: 0px 0px 0px 14.9375px;
}/*#LI_21*/
#H2_24 {
color: rgb(96, 128, 24);
height: 39px;
text-align: left;
text-rendering: optimizelegibility;
width: 220.21875px;
perspective-origin: 110.109375px 19.5px;
transform-origin: 110.109375px 19.5px;
background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(96, 128, 24);
font: normal normal bold normal 25px/39.0599975585938px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
margin: 0px 12.5999994277954px 0px 0px;
outline: rgb(96, 128, 24) none 0px;
}/*#H2_24*/
#DIV_26 {
background-position: 0px 0px;
color: rgb(0, 136, 204);
float: right;
height: 35px;
text-align: left;
width: 28.390625px;
perspective-origin: 14.1875px 17.5px;
transform-origin: 14.1875px 17.5px;
background: rgba(0, 0, 0, 0) url(http://smokefree.gov/sites/all/themes/sfg/images/content/smokefree-content-page-related-link-grn-mobile-43x43.png) no-repeat scroll 0px 0px / 90% padding-box border-box;
border: 0px none rgb(0, 136, 204);
font: normal normal normal normal 17px/20px cabinregular, Arial, Helvetica, sans-serif;
list-style: none outside none;
margin: 25px 8.39999961853027px 0px 0px;
outline: rgb(0, 136, 204) none 0px;
}/*#DIV_26*/
<aside id="ASIDE_1">
<div id="DIV_2">
<div id="DIV_3">
<img alt="Male Teen" src="http://www.battalha.com/up/pic/2.1%20smoke%20effect.jpg" id="IMG_4" />
</div>
</div>
<div id="DIV_5">
<ul id="UL_6">
<li id="LI_7">
<div id="DIV_9">
<h2 id="H2_10">
Live a smokefree life
</h2>
<p id="P_11">
Discover the rewards of quitting
</p>
</div>
<div id="DIV_12">
<img alt="" src="/sites/all/themes/sfg/images/content/spacer.png" id="IMG_13" />
</div>
</li>
<li id="LI_14">
<div id="DIV_16">
<h2 id="H2_17">
Craving cigarettes?
</h2>
<p id="P_18">
Get tips for when the urge hits
</p>
</div>
<div id="DIV_19">
<img alt="" src="/sites/all/themes/sfg/images/content/spacer.png" id="IMG_20" />
</div>
</li>
<li id="LI_21">
<div id="DIV_23">
<h2 id="H2_24">
Quitting today?
</h2>
<p id="P_25">
Review steps for your quit day
</p>
</div>
<div id="DIV_26">
<img alt="" src="/sites/all/themes/sfg/images/content/spacer.png" id="IMG_27" />
</div>
</li>
</ul>
</div>
</aside>
If you look into the source of the page you linked to, the CSS rules that are being applied that change the background color and text color are as follows:
.li-first:hover,
.li-first:hover H2,
.li-first:hover A,
.li-first:hover A:visited H2 {
background:none repeat scroll 0 0 #b56000;
color:#ffffff;
}
...
.li-second:hover,
.li-second:hover H2,
.li-second:hover A,
.li-second:hover A:visited H2 {
background: none repeat scroll 0 0 #0080ab;
color: #ffffff;
}
...
.li-third:hover,
.li-third:hover H2,
.li-third:hover A,
.li-third:hover A:visited H2 {
background: none repeat scroll 0 0 #608018;
color: #ffffff;
}
So what's actually happening is the li element itself is having its background color changed (to a different color for each of the three li elements), and the descendent elements that have text content are having both their background color and text color changed as well (text to white).
You can apply the same design to your code, taking into account the differences between your code and the site code:
#LI_7:hover, #LI_7:hover h2, #LI_7:hover p { background-color:#b56000; color:#ffffff; }
#LI_14:hover, #LI_14:hover h2, #LI_14:hover p { background-color:#0080ab; color:#ffffff; }
#LI_21:hover, #LI_21:hover h2, #LI_21:hover p { background-color:#608018; color:#ffffff; }
http://jsfiddle.net/9juf1nLf/
Edit: Sorry, I didn't notice that the image had changed! After some investigation, this is the CSS rule that's changing the image:
.li-first:hover .image-note,
.li-second:hover .image-note,
.li-third:hover .image-note {
background: url("../images/content/smokefree-content-page-related-link-ro-mobile-43x43.png") no-repeat scroll 0 0 / 90% auto transparent;
}
So what's happening is that they're replacing the entire image with an alternative one when you hover over the li. It's also a bit strange, as the .image-note class is actually being applied to a div that contains an img element. The img element is just applying a blank spacer, while the div is actually showing the visible image as its background image.
Also interesting is that they're using the exact same hover image for all three lis. This works because although the image needs to be colored differently when you're not hovering over it, when you are hovering over it, it's just the same plain white image for all three lis.
For comparison, here's the first colored image compared to the common white image:
http://smokefree.gov/sites/all/themes/sfg/images/content/smokefree-content-page-related-link-ong-mobile-43x43.png
http://smokefree.gov/sites/all/themes/sfg/images/content/smokefree-content-page-related-link-ro-mobile-43x43.png
Anyway, you can apply this to your code as well with the following:
#LI_7:hover #DIV_12, #LI_14:hover #DIV_19, #LI_21:hover #DIV_26 { background-image:url('http://smokefree.gov/sites/all/themes/sfg/images/content/smokefree-content-page-related-link-ro-mobile-43x43.png'); }
http://jsfiddle.net/9juf1nLf/2/
From Chrome's 'inspect element' it would appear that the list is using CSS :hover selector.
.li_foo:hover {
background: #B56000;color: #FFFFFF;}
More info: http://www.w3schools.com/cssref/sel_hover.asp