Can't Fix Positioning in HTML/Markup - html

Just wanna ask for your help regarding my markup, I am trying to do exactly the same like this image:
http://prntscr.com/6wrpr3
Here's my markup:
<div id="two-box">
<div class="wrapper clearfix">
<div class="column blue">
<div id="circle">
<div id="content">
<h2>PARALLAX</h2>
<h1>Text</h1>
<h2>ARE COOL!</h2>
</div>
</div>
</div>
<div class="column red">
<div id="circle-red">
<h2>LET IT</h2>
<h1>Fade</h1>
<h2>RIGHT NOW!</h2>
</div>
</div>
</div>
</div>
<div id="carport">
<div class="wrapper clearfix">
<div id="starynight"></div>
<div id="car"></div>
<div id="road"></div>
</div>
</div>
ANd now for my CSS:
.wrapper {
width: 90%;
margin: 0 auto;
max-width: 1140px;
}
.two-box{
width: 100%;
}
.column{
width: 50%;
position: relative;
padding: 40px 0;
}
.blue{
background-color: #3498db;
float: left;
}
.red{
background-color: #e74c3c;
float: right;
}
#content{
margin-top: 150px;
}
.column h2{
color: #fff;
font-family: 'Lato', sans-serif;
font-size: 3.5em;
font-weight: 300;
line-height: 1em;
text-align: center;
margin: 0;
}
.column h1{
color: #fff;
font-family: 'Pacifico', sans-serif;
font-size: 4.2em;
line-height: 0em;
text-align: center;
border-top: 4px solid #fff;
border-bottom: 4px solid #fff;
padding: 40px;
margin: 0;
}
#circle{
background-color: #3aa3e9;
border-radius: 50%;
width: 450px;
height: 450px;
margin: 0 auto;
}
#circle-red{
background-color: #f25a4a;
border-radius: 50%;
width: 450px;
height: 450px;
margin: 0 auto;
}
#road{
background: url('http://arubacontests.com/wp-content/uploads/2015/04/road.jpg') no-repeat center;
width: 1020px;
height: 145px;
display: block;
}
#car{
background: url('http://arubacontests.com/wp-content/uploads/2015/04/car.png') no-repeat center;
width: 325px;
height: 125;
display: block;
position: absolute;
z-index: 9999;
}
#starynight{
background: url('http://arubacontests.com/wp-content/uploads/2015/04/starynight.jpg') no-repeat center;
width: 1012px;
height: 768px;
display: block;
}
Here's the Codepen:
Let me know if there are things on my markup and CSS that i need to fix or show me the actual codepen. Thanks!
Note: The main issue here is the positioning of elements. Let's say I want the text and circle to be align together and not have a padding. Similar thing with the background and the car image they wont just align at all.

Something like this?
http://jsfiddle.net/4kk1fyjg/
I basically set the background-position to cover, fixed the car height (missing px at the end) and set the wrapper position to relative so that the car should be absolute positioned according to the container.
let me know if this works as expected.
Not sure about the car position, but you can adjust the position changing the right or left property
EDIT
Here you are:
http://jsfiddle.net/4kk1fyjg/2/
Just wrap the content inside another div, set the circle position to relative, display as table, the new wrapping div as table-row and the #content as table-cell, then make the table cell vertically align in the middle and that should be it.

You miss <div id="content"> in circle-red.
Remove width from #starnight and add background-size: 100% do the same for #road.
To #car change position to relative and add:
float:right;
bottom:100px;
right:150px;
To #content remove margin-top and add padding-top:125px;
And finaly for .column h1 change margin to margin: 0 40px;
hope this work how expected
JSFiddle

Related

Trying to add floating image and and description in a filled box

I am trying to get this to happen.
what I want
So far, I don't know how to overlap one img-div with another text-div and keep white space on the top of the text-div. You will see. What I have right now is:
<div id="some">
<img src="photos/some.png">
<div id="box">
<p>Proudly seeking</p>
<h2>some Cofefe</h2>
<button id="shopNow" class="button">Shop</button>
</div>
</div>
With some CSS that doesn't make it very appealing: what it looks like
#some{
margin-top: 20px;
background-color: red;
}
#some img{
width: 30%;
float: left;
}
#box{
padding-top: 220px;
margin-right: 40px;
font-family: "Eusthalia";
text-align: right;
}
#box p{
margin-right: 32%
}
h2 {
font-size: 2.6em;
}
button {
border: none;
font-family: "Eusthalia";
font-size: 15px;
background-color: #300c06;
color: #eadfc0;
padding: 2px 10px;
}
I am wondering if my whole approach with divs is wrong. I was researching and I found that right:0; doesn't work and stuff like that. How do I get a border to overlap behind the image? How do I give it a width and a height but make it push to the right?
Do I have to make the main div width 100% and then give the img a width 30% and the colored filled in text box 70%? But how would I have the box behind the img?
Drearo, I think you're doing fine with div tags. You just may need a bit more of them to help things along.
I would suggest the divs be position: absolute with the image in one of those. The box of text needs it too. Aside from that, a little CSS would get you the positioning you want. See here:
<div id="some">
<div class="my_img">
<img src="photos/some.jpg" />
</div>
<div id="box">
<p>Proudly seeking</p>
<h2>some Cofefe</h2>
<button id="shopNow" class="button">Shop</button>
</div>
</div>
css:
#some{
margin-top: 20px;
height: 100vh;
width: 100vw;
border: 1px solid #000;
position: relative;
}
.my_img {
position: absolute;
top: 5em;
left: 5em;
z-index: 200;
}
.my_img img {
width: 200px;
}
#box{
position: absolute;
top: 10em;
left: 10em;
transition: translate( -50%, -50%);
font-family: "Eusthalia";
text-align: right;
background: red;
min-width: 60%;
padding-right: 2em;
}
#box p{
margin-right: 32%
}
h2 {
font-size: 2.6em;
}
button {
border: none;
font-family: "Eusthalia";
font-size: 15px;
background-color: #300c06;
color: #eadfc0;
padding: 2px 10px;
}
https://jsfiddle.net/5k94j73p/

Vertically align an image in a div using CSS

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.

Css + html: Image relative with text over it

Since a few days I am trying to make this work. I have a design with an image with a text over it, I just finally could set the text over the image, but I want to give a top position to the image but too much space at the bottom and I don't know how to fix it!
This is what I have: I know I have to fix some padding things on the texts.
and this is my markup, by the way I am using bootstrap.
<div class="row-color clearfix">
<div class="container">
<div class="col-lg-12 no-padding wrapper">
<img class="img-responsive" src="http://s12.postimg.org/mu9u7nzvx/header_ml_02.png" alt="">
<div id="bg-text">
<div class="text-overimg">Child Education Planner</div>
</div>
</div>
<div class="texto_cursos">Face courses, distance and on-line</div>
</div>
</div>
.row-color {
background: #575756 none repeat scroll 0 0;
color: #fff;
font-size: 18px;
line-height: 1.5em;
position: relative;
z-index: 9;
padding-bottom: 20px;
}
.no-padding {
padding:0px;
}
.wrapper {
padding-left: 10px;
padding-right: 10px;
text-align:center;
position:relative;
}
.wrapper .img-responsive {
display:inline;
}
.wrapper #bg-text {
color: white;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
text-align:center;
padding-left:10px;
padding-right:10px;
}
.text-overimg{
position:relative;
font-size:3.1em;
color:#FFF;
font-weight:500;
text-shadow: 0.08em 0.08em 0.05em #333;
padding-top: 20%;
}
.texto_cursos{
padding-bottom: 10px;
font-size:2.5em;
color:#FFF;
font-weight:400;
text-align:center;
}
I would like to have this, I have to say that I want to make it responsive for most of the devices, this is one of the things I use bootstrap.
This is what I really want to have but don't know how to do it. Specially the white background behind the image without too much space between the last text and the image.
Thanks again!
** UPDATE I Accidently said if you want to move the image up a little. I meant down**
If you want to move the image down a little you can add a margin-top to it:
.wrapper .img-responsive {
display:inline;
margin-top:50px;
}
Please see JSFiddle here
try something like that:
.imagebox-container {
width: 100%;
padding-top: 30px;
background: linear-gradient(0, gray 50%, transparent 50%);
}
.imagebox img {
max-width: 100%;
display: block;
}
.imagebox-caption {
width: 100%;
text-align: center;
padding: 5px;
line-height: 1;
}
.imagebox {
position: relative;
width: 400px;
margin: 0 auto;
}
.imagebox-caption-overlay {
position: absolute;
bottom: 10px;
transition: 500ms all linear;
width: 100%;
text-align: center;
background: transparent;
color: white;
}
.imagebox:hover .imagebox-caption-overlay {
background: white;
color: black;
}
<div class="imagebox-container">
<div class="imagebox">
<img src="https://www.drupal.org/files/issues/header_1.png" />
<div class="imagebox-caption-overlay">ANOTHER BLA BLA BLA</div>
</div>
<div class="imagebox-caption">
bla bla bla
</div>
</div>
may be you need this. please see .
.imagebox-container {
width: 100%;
padding-top: 30px;
background: linear-gradient(0, gray 50%, transparent 50%);
}
.imagebox img {
max-width: 100%;
width: 400px;
margin: 0 auto;
display: block;
}
.imagebox-caption {
width: 100%;
text-align: center;
padding: 5px;
line-height: 1;
}
<div class="imagebox-container">
<div class="imagebox">
<img class="img-responsive" src="http://s12.postimg.org/mu9u7nzvx/header_ml_02.png" alt="">
</div>
<div class="imagebox-caption">
Face courses, distance and on-line
</div>
</div>

Position 3 div boxes side-by-side below a wider single div

I'm trying to get 3 divs to all be side by side below another div (that contains a h1 and a piece of small text below it). I'm having some trouble doing it.
What I am aiming for is something like this:
I've tried to put a div (that encompasses the 3 other divs) below the main title div.
I've tried this CSS:
.content-info {
text-align: center;
font-family:'Montserrat', sans-serif;
top: 80%;
left: 50%;
text-align:center;
}
/* this is for the 3 divs to set width, etc*/
.content-info div {
width:300px;
padding:25px;
margin: 25px;
}
Here is a JSFiddle of what I've got so far: http://jsfiddle.net/4zx9gxgL/
Any suggestions/ideas?
You can use display:table-row and display:table-cell to make it work similar to a table.
For example:
.content-info {
text-align: center;
font-family:'Montserrat', sans-serif;
display: table-row;
}
.content-info div {
width:300px;
padding:25px;
margin: 25px;
display: table-cell;
}
And you can remove the .one{}, .two{}, .three{} in your css
There are several ways to go about this. CSS table, float and position offer three possible solutions. Depending on your overall objectives, here's a solution featuring inline-block (no table, no float, no position). This solution is very simple, stable, responsive, and easy-to-customize.
DEMO: http://jsfiddle.net/nayztL4y/2/
HTML
<div class="container">
<h1>H1 Header</h1>
</div>
<div class="container">
<div class="boxes"><h2>Box 1</h2></div>
<div class="boxes"><h2>Box 2</h2></div>
<div class="boxes"><h2>Box 3</h2></div>
</div>
CSS
.container {
width: 90%;
height: 200px;
border: 1px solid black;
margin-bottom: 10px;
text-align: center;
background-color: #ff0;
}
.boxes {
width: 25%;
height: 180px;
border: 2px dashed red;
margin: 8px 10px;
display: inline-block;
}
UPDATE
I've updated your fiddle demo, as well.
http://jsfiddle.net/4zx9gxgL/33/
so you want to put all thre divs side by side. i think it's that .
.main-content {
text-align: center;
font-family:'Montserrat', sans-serif;
position: relative;
}
.content-info {
position: relative;
width: 100%;
height: 110px;
top: 0px;
}
.yo{
display: inline-block;
width: 33%;
margin-right: -2px;
text-align:center;
}
https://jsfiddle.net/4zx9gxgL/30/
I had a go aswell ...
#import url(http://fonts.googleapis.com/css?family=Montserrat);
body {
background: url("http://pre15.deviantart.net/52ce/th/pre/i/2011/174/b/c/candy_blur_abstract_hd_by_ivereor-d3jsglw.png") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 100%;
width: 100%;
}
.yx {
text-align: center;
}
.main-content {
text-align: center;
font-family: 'Montserrat', sans-serif;
display: block;
position: relative;
top: 20%;
left: 50%;
margin-top: 100px;
height: auto;
margin-bottom: -100px;
/* bring your own prefixes*/
transform: translate(-50%, -50%);
}
.main-content h1 {
font-size: 62px;
}
.main-content h2 {
font-size: 32px;
}
.content-info {
text-align: center;
font-family: 'Montserrat', sans-serif;
position: relative;
margin-left: auto;
margin-right: auto;
text-align: center;
}
.content-info div {
width: 300px;
padding: 25px;
margin: 25px;
}
.one {
display: inline-block;
max-width: 33%;
}
.two {
display: inline-block;
max-width: 33%;
}
.three {
display: inline-block;
max-width: 33%;
}
<body>
<div class="main-content yx">
<h1>Name Here</h1>
<h2>Hi, I'm Name.</h2>
</div>
<div class="content-info">
<div class="one">
<h3>BORAT IPSUM</h3>
<p>This is my country of Kazakhstan. It locate between Tajikistan, and Kyrgyzstan, and assholes Uzbekistan.. What's up with it, vanilla face? Me and my homie Azamat just parked our slab outside. We're looking for somewhere to post up our black asses
for the night. So, uh, bang bang, skeet skeet, nigga. Just a couple of pimps, no hoes..</p>
</div>
<div class="two">
<h3>BORAT IPSUM</h3>
<p>This is my country of Kazakhstan. It locate between Tajikistan, and Kyrgyzstan, and assholes Uzbekistan.. What's up with it, vanilla face? Me and my homie Azamat just parked our slab outside. We're looking for somewhere to post up our black asses
for the night. So, uh, bang bang, skeet skeet, nigga. Just a couple of pimps, no hoes..</p>
</div>
<div class="three">
<h3>BORAT IPSUM</h3>
<p>This is my country of Kazakhstan. It locate between Tajikistan, and Kyrgyzstan, and assholes Uzbekistan.. What's up with it, vanilla face? Me and my homie Azamat just parked our slab outside. We're looking for somewhere to post up our black asses
for the night. So, uh, bang bang, skeet skeet, nigga. Just a couple of pimps, no hoes..</p>
</div>
</div>
<footer></footer>
</body>
.content-info {
text-align: center;
font-family:'Montserrat', sans-serif;
top: 80%;
left: 50%;
float:left;
width:100%;
text-align:center;
}
/* this is for the 3 divs to set width, etc*/
.content-info div {
width:300px;
padding:25px;
margin: 25px;
float:left;
}
If the 3 bottom divs don't align correctly remove the margin settings, or adjust accordingly.

The boxes float out of the footer

Need help to fix the footer. One of the boxes fals out of the footer. All 3 should be in a line, next to each together. The Css is uploaded and html showed. However i've tried a lot of stuff but seems nothing to be working. however the right box always out of the footer, i cloudn't figure out the problem
so please it would be great to get some help and understand exactly where i did go wrong so i can learn it
thank you :D
Css and html
<%-- Footer --%>
<div id="footer">
<div id="footer_placement">
<div id="left">
<p></p>
</div>
<div id="middel">
<p></p>
</div>
<div id="right">
</div>
</div>
</div>
<%-- Footer --%>
#footer {
bottom: 0;
width: 100%;
display: block;
background-color: #fff;
max-height: 50px;
}
#footer_placement {
max-width: 1024px;
margin: 0 auto;
display: block;
max-height:50px;
}
#right {
float: right;
height: 50px;
width: 298px;
background-color:black;
}
#right img {
height: 50px;
width: 50px;
}
#middel {
height: 50px;
margin: 0 auto;
width: 300px;
background-color:black;
}
#middel p {
text-align: center;
color: #321a51;
font-size: 12px;
font-family: muli;
}
#left {
width: 298px;
height: 50px;
float:left;
background-color:black;
}
#left p {
text-align: center;
color: #321a51;
font-size: 12px;
font-family: muli;
}
use display:inline-block; for this ids: middle - left - right
Fiddle
Your problem is the width of the left right and middle divs .
They don't really add up .. try to change the width .. make it smaller
jsFIDDLE example