I'm trying to get a vertical bar graph made in css, so it appears to look like this:
But it's flipped upside down with my code. How can the CSS elements be aligned from the bottom?
HTML:
<div id="skill">
<div><span class="bar nrml"></span>
<span class="bar moderate"></span><span class="bar severe"></span>
</div>
CSS:
#skill {
font: 12px "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
height: 200px;
position: relative;
padding: 0px 0;
}
#skill div {
margin-bottom: 0px;
background: #e9e5e2;
width: 1em;
border-radius: 10px;
height: 200px;
}
.bar {
width: 1em;
height: 200px;
margin: 1px 2px;
position: absolute;
border-radius: 10px;
}
.severe {
height: 25%;
background-color: #f674a4;
}
.moderate {
height: 50%;
background-color: #f0bb4b;
}
.nrml {
height: 100%;
background-color: #a1ce5b;
}
JSFiddle
You have to just add bottom:0; to the class .severe. Here a new updated fiddle: https://jsfiddle.net/sebastianbrosch/yoqhkpwh/2/
Related
My banner is meant to be directly under the navigation bar but as of now, there is a space between it. I tried to use top for css and it doesn't move.
The css for the banner is:
/*Index CSS*/
* {
margin:0px; padding: 0px;
}
body {
position: absolute;
width: 1250px;
height: auto;
margin-left: auto;
margin-right: auto;
}
#wrapper {
background-color: rgb(161, 193, 217);
position: absolute;
width: 1250px;
height: auto;
margin-left: 5px;
margin-right: 5px;
}
#welcome {
background: url(../Resources/Header/CUiZMwBXAAAQy1M.jpg);
width: 1250px;
height: 480px;
}
#WelcomeTo {
color: white;
font-size: 55px;
text-align: center;
font-family: Bebas;
margin-top: 100px;
}
#LittleChef {
color: white;
font-size: 60px;
text-align: center;
font-family: Candy Shop Personal Use;
}
<div id="welcome" name="banner">
<div id="WelcomeTo" name="WelcomeTo">
<h1>WELCOME<br>TO</h1>
</div>
<div id="LittleChef" name="LittleChef">
<h1>Little Chef</h1>
</div>
</div>
I've had this problem for a very long time. Here is a screenshot to what it looks like as of now.
it is because the margin of your h1 element.
the solution is set the margin-top of h1 to 0.
Or you can set the padding of the wrapper
I am trying vertical align an image in a div. I have a div which displays a coloured background and I need to place other objects inside that div, but centred vertically.
I have craeted a sjfiddle to try and explain.
JSFiddle
First of all you should get rid of the margin-top: -60px in .room-name . Then there are two texts, not just one. Take a look at the settings below, I think that might be what you want (?) The essential part for the centering is the relative position, to: 50% and transform: translatey(-50%), but also the background position for the background image.
#wrapper-new {
width: 100%;
}
#record-section {
width: 100%;
float: left;
height: 100%;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #333;
height: 80px;
}
#room-section {
width: 20%;
background-color: #E9E9E9;
display: inline-block;
float: left;
height: 80px;
}
.direction-image {
display: inline-block;
background-repeat: no-repeat;
background-image: url(https://s2.postimg.org/te7o9w9ix/orbitor_small_17.png);
background-position: 0 center;
position: relative;
top: 50%;
transform: translateY(-50%);
}
.room-name {
font-family: Tahoma, Geneva, sans-serif;
font-size: 30px;
font-weight: bold;
color: #006;
display: inline-block;
margin-left: 100px;
width: 200px;
float: left;
margin-right: 30px;
}
.floor-name {
font-family: Tahoma, Geneva, sans-serif;
font-size: 26px;
font-weight: bold;
color: #666;
}
<div id="wrapper-new">
<div id="record-section">
<div id="room-section">
<div class="direction-image">
<div class="room-name">Box
<div class="floor-name">Ground</div>
</div>
</div>
</div>
</div>
</div>
To vertically center children you just need to add display: flex and align-items: center for element immediate parent and all its children will be centered vertically.
Using your markup it will be something like (also removed negative top-margin from your styles):
#wrapper-new {
width: 100%;
}
#record-section {
width: 100%;
float: left;
height: 100%;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #333;
height: 80px;
}
#room-section {
width: 20%;
background-color: #E9E9E9;
display: inline-block;
float: left;
height: 80px;
}
.direction-image {
margin-top: 8px;
vertical-align: middle;
background-repeat: no-repeat;
background-image: url(https://s2.postimg.org/te7o9w9ix/orbitor_small_17.png);
}
.room-name {
font-family: Tahoma, Geneva, sans-serif;
font-size: 30px;
font-weight: bold;
color: #006;
/* remove display: inline-block; */
display: flex; /* new */
align-items: center; /* new */
/* remove margin-top: -60px; */
margin-left: 100px;
width: 200px;
float: left;
margin-right: 30px;
}
.floor-name {
font-family: Tahoma, Geneva, sans-serif;
font-size: 26px;
font-weight: bold;
color: #666;
}
<div id="wrapper-new">
<div id="record-section">
<div id="room-section">
<div class="direction-image">
<div class="room-name">Box
<div class="floor-name">Ground</div>
</div>
</div>
</div>
</div>
</div>
If you don't want to use flexbox (which is not supported by older browsers) you can add line-height: 100px (or some other number) (if parent has height 100px)
.box{
height:100px;
width:100px;
color:white;
background-color:red;
line-height:100px;
}
<div class="box">
Text inside box
</div>
Try flexbox: JSFiddle.
<div id="wrapper-new">
<div id="record-section">
<div id="room-section">
<div class="direction-image">
<div class="room-name">Box
<div class="floor-name">Ground</div>
</div>
</div>
</div>
</div>
.wrapper {
width: 200px;
height: 200px;
display: flex;
align-items: center;
background-color: #FFFFFF;
}
You can change how you vertically align inner items by changing the wrapper's align-items property to center.
I have a problem with a to fixed divs in the right and left bottom corner. On a desktop they look good, the divs are in the corner. However, when on mobile, the divs are fixed and overlap the rest of the content. I tried a margin-bottom but that didn't fix the problem.
What I want is that the two info divs are fixed but when you are on mobile that there is a gap between the info divs and the div class="wrap".
Here's my html
<div class="wrap">
<h1 class="titel">Media Media B.V.</h1>
</div>
<div class="info container">
<div class="row">
<div class="address col-md-6">
<p><strong>Media Media B.V.</strong><br/>
Vriendsgracht 77<br/>
2542AH Utrecht<br/>
The Netherlands</p>
<p><abbr title="Phone">Skype:</abbr> john.doe<br/>
info#media.nl</p>
</div>
<div class="vat col-md-6">
<p><abbr title="Chamber of Commerce">CoC:</abbr> 4444444<br/>
<abbr title="Value Added Tax">VAT:</abbr> NL444444444</p>
</div>
</div>
</div>
This is the css i used
body {
background-color: #1A4C62;
height: 100%;
}
.wrap {
background-color: blue;
margin-bottom: 7.5%;
position: relative;
}
.titel {
color: #fff;
font-family: 'Lato', sans-serif;
text-align: center;
padding-top: 7.5%;
}
.titel2 {
color: #fff;
font-family: 'Lato', sans-serif;
text-align: center;
}
.logo {
margin: 0 auto;
}
.ondertitel {
color: #fff;
font-family: 'Lato', sans-serif;
text-align: center;
}
.info {
color: #fff;
font-family: 'Lato', sans-serif;
}
div.info {
width: 100%;
}
div.info div p {
margin: 2px 0px 5px 0px;
}
div.info div strong {
display: inline-block;
font-size: 13px;
}
div.info .address {
position: fixed;
bottom: 0;
left: 0;
width: 150px;
padding: 10px 25px 10px 15px;
border: 1px solid #fff;
}
div.info .vat {
position: fixed;
bottom: 0;
right: 0;
width: 150px;
padding: 10px 15px 10px 25px;
border: 1px solid #fff;
}
You use only col-md rules, set col-sm and col-xs attributes to your HTML and it should solve the problem for mobiles
I'm playing with CSS divs as a chart and I'm trying to make a stacked chart where the div equals 100% of the width of a div and the left portion of the bar is one color and the other portion of the bar is another. Right now I have:
.chart div {
font: 25px sans-serif;
background-color: #2c3e50;
text-align: right;
padding: 3px;
margin: 1px;
color: white;
}
<div class="chart">
<div style="width: 49.81%;">1, $4,980,777</div>
<div style="width: 41.10%;">2, $4,109,778</div>
</div>
Here is the https://jsfiddle.net/j63grq88/
Try adding display: inline-block; to both divs
TRY THIS:
.chart{
overflow-x:hidden;
}
.chart div {
font: 25px sans-serif;
background-color: #2c3e50;
text-align: right;
padding: 3px;
margin: 1px;
color: white;
position: relative;
}
.chart div:after{
content: '';
position: absolute;
top:0;
left:0;
width: 300%;
height: 100%;
background: red;
z-index: -1;
}
<div class="chart">
<div style="width: 49.81%;">1, $4,980,777</div>
<div style="width: 41.10%;">2, $4,109,778</div>
</div>
I have the following code:
<div id="conteudo">
<img id="logo" height="137" width="327" />
<div id="data_hora">
</div>
<div id="nome_patio">
<div id="cor_patio"></div> #NOME_PATIO#
</div>
</div>
css:
body
{
background-color: #000000;
margin: 0;
padding: 0;
font-family:Arial;
}
#conteudo
{
height: 100%;
width: 100%;
}
#data_hora
{
float: right;
font-size: 50px;
color: #E0E428;
margin-top: -90px;
margin-right: 40px;
}
#nome_patio
{
text-align: center;
font-size: 80px;
color: #E0E428;
width: 100%;
font-weight: bold;
}
#cor_patio
{
border: solid 1px #FFFFFF;
height: 10px !important;
width: 80px;
background-color: #E0E428;
margin-right: 20px;
}
So, i'm trying to change the div cor_patio height, but nothing happens... why?
OBS: when i remove font-size from nome_patio, it works fine.
try to set position:absolute; to home_patio, if it doesn't work, also set to cor_patio.
Set position:relative; to #nome_patio and position:absolute; to #cor_patio;
Hope it help.
You need to set your height on #nome_patio to 100%.
Working example: http://jsfiddle.net/aYnyk/
I solve the solution with this:
<div id="patio">
<span id="cor_patio"></span><span id="nome_patio">#NOME_PATIO#</span>
</div>
css:
#patio
{
text-align: center;
width: 100%;
}
#cor_patio
{
height: 63px;
width: 63px;
background-color: #E0E428;
margin-right: 30px;
}
#nome_patio
{
font-size: 80px;
color: #E0E428;
font-weight: bold;
}