The text inside of my progress bars are getting cut off on the top. I'd like to move the text to the middle of the progress bar.
How can I do so?
I've tried position: relative; and top: 40px but that is causing issues for me when I dynamically change the number (with JS). Oddly, the number is getting cut off on the top even when it appears in the middle of the progress bar. Even more odd is that is only happening in Chrome (FF and IE work fine).
Notice in this image, only the bottom changed, but the top part didn't:
So, I included a live example WITHOUT the relative positioning, I'm thinking that that is the reason things are wacky. Can you guys figure out how to just move the text down to the middle without relative positioning? Or just figure out how to prevent the number from getting cut off with the relative positioning?
Also, I don't want absolute positioning either because the number needs to remain in the middle of each individual progress bar.
LIVE EXAMPLE: http://jsfiddle.net/SeTXK/1/
HTML:
<div class="row">
<div class="col-md-12">
<div class="content">
<h2>Summary</h2>
<div class="progress text-center">
<div class="progress-bar progress-bar-success" role="progressbar">
<span id="output-expenses">$0.00</span>
</div>
<div class="progress-bar progress-bar-warning" role="progressbar">
<span>$0.00</span>
</div>
<div class="progress-bar progress-bar-danger" role="progressbar">
<span>$0.00</span>
</div>
<div class="progress-bar progress-bar-income" role="progressbar">
<span id="output-income"></span>
</div>
</div>
</div>
</div>
</div>
CSS:
.progress {
height: 100px;
margin-bottom: 0;
border-radius: 10px;
/*background-color: #c4ffc4;*/
}
.progress span {
/*position: relative;
top: 40px;*/
color: #292929;
font-weight: bold;
font-size: 4em;
font-family: 'Cinzel', serif;
text-align: center;
vertical-align: middle;
width: 100%;
}
.progress-bar-success {
width: 30%;
}
.progress-bar-warning {
width: 20%;
}
.progress-bar-danger {
width: 20%;
}
.progress-bar-income {
background-color: #f5f5f5;
-webkit-box-shadow: inset 0 5px 8px rgba(0,0,0,0.1);
box-shadow: inset 0 5px 8px rgba(0,0,0,0.1);
width: 30%;
}
If you add padding-top:75px; display:inline-block; to the .progress span rule, it will achieve the desired effect.
jsFiddle
Related
I have an element with a slanted bottom-right corner, over which I have to lay a box-shadow. Sometimes the slanted corner is covered up by a badge - my problem does not apply, if that is the case:
This is the (s)css part for the infobox and its corners (there are some more styles, but they're just text modifiers... The whole thing is on codepen: https://codepen.io/kerowan/pen/bqMOeB
.product-info-wrapper {
position: absolute;
top: 150px;
max-width: 100%;
padding-bottom: 10px;
width: 100%;
.product-info {
position: relative;
padding: 1rem * .5;
padding-right: 1rem * 2;
overflow: hidden;
box-shadow: 0 0 5px;
&:before,
&:after {
position: absolute;
content: "";
left: 0;
z-index: -1;
background-color: lighten(#000, 93.5%);
border-color: lighten(#000, 93.5%);
}
&:before {
top: 0;
right: 0;
bottom: 35px;
}
&:after {
top: auto;
right: -5px;
bottom: 0;
border-style: solid;
border-width: 35px 35px 0 0;
background-color: transparent;
border-right-color: transparent;
}
}
}
How can this be done (moving the shadow along the slanted corner)? Can it be done, if the slanted corners are generated the way I do it? I'm kind of dependant on those classes (I think at least) because of all the relative and absolute positioning, which I needed to place the corner badge.
EDIT: some HTML, if you need it:
<div class="swiper-slide">
<div class="product-info-wrapper">
<div class="product-info">
<div class="row no-gutters">
<div class="col-8">
<strong class="text-uppercase">Amino Force</strong>
<span class="product-info-link">Kurzinfo</span>
</div>
<div class="col-4 text-right">
<span class="product-info-price">CHF 34.00</span>
</div>
</div>
</div>
</div>
</div>
<div class="swiper-slide">
<div class="product-info-wrapper">
<div class="product-info">
<div class="row no-gutters">
<div class="col-8">
<strong class="text-uppercase">Amino Force</strong>
<span class="product-info-link">Kurzinfo</span>
</div>
<div class="col-4 text-right">
<span class="product-info-price">CHF 34.00</span>
</div>
</div>
</div>
<div class="product-badge-wrapper">
<div class="product-badge red">
<div class="product-badge-content">
new
</div>
</div>
</div>
</div>
</div>
This is just part of the whole HTML code which can be found on the codepen thingy. But I guessed, that this would be the only relevant part. If you need more, please tell me!
EDIT2
The contents of this infobox can be expanded. If I click on "Kurzinfo", it expands and shows more info. That's not on the codepen version, as I created it way before I added the expansion functionality.
It is normally impossible, because the slanted corner is a part of border of element that is not visible.
In image if the blue area changes to white you have a slanted corner black area, that is a part of border and in css we can not any think to change this.(change as you want).
You can cover the shadows by adding two little divs to the product div:
<div class="product-info-wrapper">
<div class="coverShadow c1"></div>
<div class="coverShadow c2"></div>
....
And CSS:
.coverShadow {
position: absolute;
z-index: 999;
background-color: white;
box-shadow: 0 0 14px white;
}
.coverShadow.c1 {
width: 10px;
height: 35px;
background-color: white;
bottom: 8px;
right: -10px;
}
.coverShadow.c2 {
width: 35px;
height: 10px;
bottom: 0px;
right: 0;
}
By changing the box shadow and width/height and right/bottom of covering divs it could be more smooth.
And thanks for the good idea for creating slanted corners.
As of 2022 you could get rid of the elements and styles .coverShadow, .coverShadow.c1 and coverShadow.c2 suggested by #Farzin's answer. Instead, for the .product-info element replace
box-shadow: 0 5px 5px
with
filter:drop-shadow(0 0 5px #333)
(blur amount and color might need to be adjusted).
The drop-shadow() will adapt to any shape, not just rectangles. It will also work in most modern browsers.
This question already has answers here:
My inline-block elements are not lining up properly
(5 answers)
Closed 7 years ago.
I am running into an issue that I am unsure of the cause. I had three boxes that I want lined up in a horizontal line, which they are until I added my title and descriptions inside of the boxes. Why would adding the titles and descriptions make this staggering effect?
You can see what it is doing inside of my snippet.
#home-img-block-wording-container {
width: 100%;
height: 400px;
border: 1px solid black;
}
.home-img-wording-blocks {
width: 33%;
height: 100%;
text-align: center;
border: 1px solid black;
display: inline-block;
}
.home-img-wording-block-title {
padding-top: 20px;
font-size: 2em;
}
.home-img-wording-block-description {
padding: 25px 20px 0 20px;
font-size: 1.2em;
color: #adadad;
}
<div id="home-img-block-wording-container">
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">WEB DESIGN</div>
<div class="home-img-wording-block-description">The OD team can see your web design visions brought to life, creating a site that promotes your uniqueness through specific functionalities and features.</div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">ECOMMERCE</div>
<div class="home-img-wording-block-description">Custom built solutions catered towards you end goal.</div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">MARKETING STRATEGIES</div>
<div class="home-img-wording-block-description">MARKETING STRATEGIES</div>
</div>
</div>
The problem is that the text in each inline-block .home-img-wording-blocks element is being aligned to the baseline of the previous box.
As stated by the relevant specification:
10.8 Line height calculations: the line-height and vertical-align properties
The baseline of an inline-block is the baseline of its last line box in the normal flow, unless it has either no in-flow line boxes or if its overflow property has a computed value other than visible, in which case the baseline is the bottom margin edge.
It's worth pointing out that the default value for the vertical-align property is baseline. To fix your problem, you could align the element to the top by adding vertical-align: top:
#home-img-block-wording-container {
width: 100%;
height: 400px;
border: 1px solid black;
}
.home-img-wording-blocks {
width: 33%;
height: 100%;
text-align: center;
border: 1px solid black;
display: inline-block;
vertical-align: top;
}
.home-img-wording-block-title {
padding-top: 20px;
font-size: 2em;
}
.home-img-wording-block-description {
padding: 25px 20px 0 20px;
font-size: 1.2em;
color: #adadad;
}
<div id="home-img-block-wording-container">
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">WEB DESIGN</div>
<div class="home-img-wording-block-description">The OD team can see your web design visions brought to life, creating a site that promotes your uniqueness through specific functionalities and features.</div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">ECOMMERCE</div>
<div class="home-img-wording-block-description">Custom built solutions catered towards you end goal.</div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">MARKETING STRATEGIES</div>
<div class="home-img-wording-block-description">MARKETING STRATEGIES</div>
</div>
</div>
Just set vertical-align: top; to the .home-img-wording-blocks item
A solution by hiding the overflow of your divs and making sure no unintentional margins or padding are being applied:
* {
margin:0;
padding:0;
}
#home-img-block-wording-container {
width: 100%;
height: 400px;
border: 1px solid black;
}
.home-img-wording-blocks {
width: 33%;
height: 100%;
text-align: center;
border: 1px solid black;
display: inline-block;
overflow:hidden;
}
.home-img-wording-block-title {
padding-top: 20px;
font-size: 2em;
}
.home-img-wording-block-description {
padding: 25px 20px 0 20px;
font-size: 1.2em;
color: #adadad;
}
<div id="home-img-block-wording-container">
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">WEB DESIGN</div>
<div class="home-img-wording-block-description">The OD team can see your web design visions brought to life, creating a site that promotes your uniqueness through specific functionalities and features.</div>
</div><div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">ECOMMERCE</div>
<div class="home-img-wording-block-description">Custom built solutions catered towards you end goal.</div>
</div><div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">MARKETING STRATEGIES</div>
<div class="home-img-wording-block-description">MARKETING STRATEGIES</div>
</div>
</div>
New to using bootstrap, and am having trouble with a div rectangle that I would like to stretch full-width across the top of the page (much like the SO grey bar at the top). I have tried sizing to 100% and resetting margins, but nothing is working. I also tried taking the rectangle out of the container div, but then it disappears :(. I then tried making the rectangle a well instead, but that doesn't seem to want to let me set its height to 20px.
I've tried most of the rearranging-of-divs or using the !important as suggested on SO, but, for whatever reason, the divs aren't cooperating. I just want a blue bar to stretch across the top of the page, as per my bosses request :P
I'm a bit frustrated, and wonder if anyone can help me?
<body>
<div class="container">
<div class="rectangle span12"></div>
<div class="container">
<div class="row-fluid">
<span class="span12">
<img src="images/one-pager-blogcta-08.png" class="pull-right image">
</span>
</div>
</div>
and the CSS
body {
padding-left: 0;
padding-right: 0;
}
/* Set floating dom-heading margins to 0 */
[class*="dom-heading"] {
margin: 0;
}
.container .rectangle {
background: #1f2f5f;
-moz-box-shadow: none;
-webkit-box-shadow: none;
-o-box-shadow: none;
box-shadow: none;
border-radius: 0px;
margin-left: 0px !important;
border: none;
height: 20px;
width:100%;
}
Site: intervalmed.com
Html:
<body>
<div class="navbar rectangle">
<div class="container-fluid">
<!--menu items-->
</div>
</div> <!-- .navbar -->
<div class="container">
<div class="container">
<div class="row-fluid">
<span class="span12">
<img src="images/one-pager-blogcta-08.png" class="pull-right image">
</span>
</div>
</div>
CSS:
.rectangle {
background: #1f2f5f;
-moz-box-shadow: none;
-webkit-box-shadow: none;
-o-box-shadow: none;
box-shadow: none;
border-radius: 0px;
margin-left: 0px !important;
border: none;
height: 20px;
width:100%;
}
If you just want the bar on top, you can just set a border to <body>
body {
border-top: solid 20px #1f2f5f;
}
If you want an actual <div> with 100% of the document's width, then it should be outside the container, since the container is the one that wraps things with max-width
So just move your div outside container and set the height explicitly in your CSS (<div> elements will always fill it's parents width)
HTML
<body>
<div class="rectangle"></div>
<!-- THE REST OF YOUR PAGE -->
</body>
CSS
.rectangle {
background: #1f2f5f;
height: 20px;
}
I've searched the many similar questions like this, but none of the solutions are working. It should also be noted that I am using twitter bootstrap. I want a bunch of divs to span the entire length of the parent div at the bottom of it. I have tried putting them inside a div that text-align:center and then using float-left inside the gridPics class, and using display: inline-block, text-align :left and nothing seems to do it. The two in the example below are in the exact same spot, and I want them side by side. Here is what I have:
HTML:
<div class="row-fluid">
<div class="span8 offset2 articleContent">
<!-- These are the divs to span across, when it works there would be more than two -->
<div class="gridPics"></div>
<div class="gridPics"></div>
<!-- They will also go over this image -->
<img id="sidePic" src="img/about/aboutHeader_Mid1.png" alt="about">
</div>
<div class="span2"></div>
</div>
CSS:
.gridPics{
position: absolute;
z-index: 1;
width: 10%;
height: 20%;
background: #0000b3;
bottom: 0;
float: left;
}
.articleContent{
position: relative;
box-shadow: 0 0 5px 5px #888;
}
#sidePic{
position: relative;
z-index: -1;
}
Here is where I am doing this, the blue divs would be pics (akin to thumbnails) that can be clicked. I want them to go all the way across:
/ScreenShot2013-01-09at85450PM_zps550e8e4a.png[/IMG]
Here's a fiddle:
http://jsfiddle.net/pureux/Er9eG/
You need a container for your gridPics and have it be absolute positioned (instead of the gridPics) at the bottom. Then float the gridPics inside of the container.
.picContainer {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
min-height: 50px;
}
.gridPics {
width: 50px;
height: 50px;
float: left;
display: block;
margin-right: 4px;
margin-top: 4px;
}
Is this what you're trying to do:DEMO
HTML
<div class="row-fluid">
<div class="span8 offset2 articleContent">
<div class="gridPics"></div>
<div class="gridPics"></div>
<div class="clear"></div>
<img id="sidePic" src="img/about/aboutHeader_Mid1.png" alt="about">
</div>
<div class="span2"></div>
</div>
CSS
.gridPics{
width: 10%;
height: 20px;
background: #0000b3;
float: left;
border:solid #FFF 1px;
}
.articleContent{
box-shadow: 0 0 5px 5px #888;
}
#sidePic{
z-index: -1;
}
I am a iPhone developer stuck with some basic CSS properties ;)
I want to show something like this:
This is what I have:
<div class="cell">
<div class="cell_3x3_top">
<div class="cell_3x3_type rounded_left">type</div> <!--UPDATED:2010/09/29-->
<div class="cell_3x3_title rounded_right">title</div><!--UPDATED:2010/09/29-->
</div>
<div class="cell_3x3_content rounded_left rounded_right">content</div><!--UPDATED:2010/09/29-->
</div>
and the css:
div.cell_3x3_top{
height:20%;
margin: 0 0 0 0;
padding: 0 0 0 0;
border: none;
margin-bottom: 1px; /*to compensate space between top and content*/
text-align: center;
vertical-align: middle;
}
div.cell_3x3_type{
width:20%;
float:left;
background-color: inherit;
margin-right: -2px; /*UPDATED:2010/09/29*/
}
div.cell_3x3_title{
width:80%;
float:left;
background-color: inherit;
margin: 0 0 0 0; /* maybe not neccesary*/
padding: 0 0 0 0; /*maybe not neccesary*/
margin-left: -1px; /*UPDATED:2010/09/29 */
}
div.cell_3x3_content{
height:80%;
background-color: inherit;
}
But when I render my content with above code title div seems to be too large and it appears underneath type div, Why is this?
type div is 20% width, title is 80% width so it should be 100% exactly. Is any margin or other metric I am forgetting here?
I have tried to move title div to the left using margin but is still buggy. I wonder what is the correct way of getting something like the picture?
(Not exactly because if you look closer title div is a little bit shorter than it should be. See that its right border is not aligned with content div.)
Thanks in advance.
EDIT: 2010/09/28
This is actually what I want to achieve:
and this is what I have:
Above code (updated a little bit) would work if I wouldn't have bordered divs. Since border width is 1px what I need is to set type div width to 20%-2px (left border + right border = 2px) and title div to 80%-2px
.rounded_left{
border-top-left-radius: 4px 4px;
border-bottom-left-radius: 4px 4px;
border-color:gray;
border-width: 1px;
border-style:solid;
}
(.rounded_right is similar)
This is not related to clear:both property I believe. I tried and didn't had any effect since my content div was good form the beginning.
In short: How can I make a div including its border to be let's say exactly 20% width?
Ignacio
ANSWER:
I realized that a wrapper div around type and title respectively solves the problem. So my answer is kind of like this:
<td class="cell">
<div class="cell_3x3_top bordered">
<div class="cell_3x3_type_container"><div class="cell_3x3_type rounded_left full_height">6</div></div>
<div class="cell_3x3_title_container"><div class="cell_3x3_title rounded_right full_height">title</div></div> </div>
<div class="cell_3x3_content rounded_left rounded_right">content</div>
</td>
I set 20% and 80% in the containers and the borders in the inner div.
You are missing a clearing div. The floating elements do not expand the .cell_3x3_type div as you would expect. Try this instead:
<div class="cell">
<div class="cell_3x3_top">
<div class="cell_3x3_type">type</div>
<div class="cell_3x3_title">title</div>
<div class="cell_3x3_clear"></div>
</div>
<div class="cell_3x3_content">content</div>
</div>
CSS:
div.cell_3x3_clear {
clear: both;
}
The rest remains the same.
EDIT:
A small explanation of what the clear property does: consider a container div that contains only floated elements, like this (using inline CSS for clarity):
<div id="container" style="border: 1px solid green;">
<div style="float: left; height: 30px; width: 30px; border: 1px solid red;"></div>
<div style="float: left; height: 20px; width: 20px; border: 1px solid blue;"></div>
</div>
(source: fii.cz)
The height of the container div is 0 because the floating elements are taken out of the document flow and do not affect the height of their container anymore. The clear: both property on an element "clears" all floats, i.e. makes sure that the element is placed below all floating elements that precede it:
<div style="float: left; height: 30px; width: 30px; border: 1px solid red;"></div>
<div style="float: left; height: 20px; width: 20px; border: 1px solid blue;"></div>
<div style="clear: both; height: 10px; width: 50px; border: 1px solid black;">Cleared</div>
(source: fii.cz)
If you combine the two above examples, you can force the container div to have its height equal to the height of the highest floating element in it:
<div id="container" style="border: 2px solid green;">
<div style="float: left; height: 30px; width: 30px; border: 1px solid red;"></div>
<div style="float: left; height: 20px; width: 20px; border: 1px solid blue;"></div>
<div style="clear: both; height: 0px; border: 1px solid black;"></div>
</div>
(source: fii.cz)