Position image next to div perfectly - html

How do i place the image perfectly like this in various screen sizes?
.background-login {
background: url(../img/login.png) no-repeat;
background-size: 100%;
z-index: -2;
position: absolute;
top: 8%;
min-height: 400px;
right: 2%;
height: 100%;
}
.background-login-create {
background: url(../img/login.png) no-repeat;
background-size: 100%;
z-index: -2;
position: absolute;
top: 17%;
min-height: 400px;
right: 2%;
height: 100%;
}
.background-login-create-profile {
background: url(../img/login.png) no-repeat;
background-size: 100%;
z-index: -2;
position: absolute;
top: 13%;
min-height: 400px;
right: 2%;
height: 100%;
}
.sellfie-start-text {
font-size: 15px;
padding: 145px;
text-align: center;
font-weight: 200;
position: relative;
top: 8%;
vertical-align: middle;
color: #FFF;
}
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container div-login">
<div class="row">
<div class="col-sm-5 col-md-offset-1">
<div class="center">
<h2 class="login-title"></h2>
<h4></h4>
<p class=""></p>
</div>
<div class="account-wall">
<p class="profile-name">Hello!<span style="color:red">:)</span></p>
<p class="profile-desc">We require only your mobile number for both login and signup</p>
<br>
<div class="form-signin">
<div class="md-form">
<input type="text" placeholder="Enter Mobile Number" value="" name="mobile_number" id="mobile_number" class="mobile_number form-control">
</div>
<button class="btn btn-main btn-continue" id="continue">
CONTINUE</button>
<div class="form-signin-bottom">By clicking on Continue, you agree to our Privacy Policy
& Terms
</div>
</div>
</div>
</div>
<div class="col-sm-6 background-login">
<div class="sellfie-logo">
<img src="img/sellfie_white.png"/>
</div>
<div class="sellfie-start-text">
Sellfie is the easiest way to sell online and collect payments for your products & services on social networks
and online channels.
</div>
</div>
</div>
</div>
What if the left container is larger i want my right image to be the same height as the left container?
.background-login {
background: url(../img/login.png) no-repeat;
background-size: cover;
z-index: -2;
position: absolute;
margin-top: 50px;
right: 2%;
min-height:400px;
height: 100%;
}

I have added wrapper inside background-login element and some CSS to make it center aligned.
In .background-login CSS, set background-size: cover (this will make image cover the whole element)
I also removed top and right values, don't set position values on Bootstrap columns because they will break the layout.
body {
background-color: #ddd !important;
}
.form-left,
.background-login {
height: 400px;
}
.form-left {
background-color: white;
}
.background-login {
position: relative;
background: url(https://unsplash.it/600/400) no-repeat;
background-position: center center;
background-size: cover;
}
.background-login .wrapper {
position: absolute;
top: 50%;
transform: translateY(-50%);
padding: 30px;
text-align: center;
}
.sellfie-start-text {
font-size: 15px;
text-align: center;
font-weight: 200;
position: relative;
top: 8%;
vertical-align: middle;
color: #FFF;
}
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container div-login">
<div class="row">
<div class="col-sm-5 col-md-offset-1 form-left">
<div class="center">
<h2 class="login-title"></h2>
<h4></h4>
<p class=""></p>
</div>
<div class="account-wall">
<p class="profile-name">Hello!<span style="color:red">:)</span></p>
<p class="profile-desc">We require only your mobile number for both login and signup</p>
<br>
<div class="form-signin">
<div class="md-form">
<input type="text" placeholder="Enter Mobile Number" value="" name="mobile_number" id="mobile_number" class="mobile_number form-control">
</div>
<button class="btn btn-main btn-continue" id="continue">
CONTINUE</button>
<div class="form-signin-bottom">By clicking on Continue, you agree to our Privacy Policy
& Terms
</div>
</div>
</div>
</div>
<div class="col-sm-6 background-login">
<div class="wrapper">
<div class="sellfie-logo">
<img src="img/sellfie_white.png"/>
</div>
<div class="sellfie-start-text">
Sellfie is the easiest way to sell online and collect payments for your products & services on social networks
and online channels.
</div>
</div>
</div>
</div>
</div>

#details {
display: inline-block;
vertical-align:middle;
border:solid black 1px;
width: 300px;
}
.photo {
display: inline-block;
vertical-align:middle;
width: 300px;
height: 300px;
border: 1px solid #d1c7ac;
}

Related

How to place card over image in bootstrap?

I'm now working on a website. I tried several times to place the card over the picture. Can you have any suggestions?https://i.stack.imgur.com/goigA.png
one way is set minus margin-top for example: margin-top : -100px
.tag {
position: relative;
left: 0px;
background-color: green;
z-index: 1000;
margin-top: -50px;
width: 100px;
height: 100px;
margin-right: 20px;
}
.d-flex{
display: flex;
}
<div class="container">
<img src="https://homepages.cae.wisc.edu/~ece533/images/arctichare.png">
<div class="d-flex">
<div class="tag">Featured</div>
<div class="tag">Featured</div>
<div class="tag">Featured</div>
<div class="tag">Featured</div>
</div>
</div>

Placing div on image

How i can place my div with button, form and other content on an image like this picture. I have already placed the text on this image using this code:
.img-wrap {
position: relative;
}
.img-wrap h1 {
position: absolute;
left: 41.5%;
bottom: 45%;
background: rgba(255, 255, 255, 0.9);
height: 20%;
width: 17%;
padding: 3% 0px 0px 2.4%;
font-size: 2.3vw;
font-weight: bold;
color: rgba(0, 0, 0, 1);
font-family: Alegreya Sans black;
}
<div class="container-fluid">
<div class="row">
<div class="img-wrap">
<img src="...\images\main-foto.jpeg" class="img-responsive">
<h1>Funny Island</h1>
</div>
</div>
</div>
I tried to place my div on the same way, but it doesn't work.
.img-wrap {
position: relative;
}
.img-wrap div {
position: absolute;
width: 1000px;
height: 900px;
background-color: grey;
}
<div class="container-fluid">
<div class="row">
<div class="img-wrap">
<img src="...\images\main-foto.jpeg" class="img-responsive">
<h1>Funny Island</h1>
<div>
</div>
</div>
</div>
</div>
Thanks for the help
Add the image as a background image on .img-wrap. You can then add the buttons, text etc inside the div.
.img-wrap {
position: relative;
background-image: url( 'http://placekitten.com/500/300' );
background-size: cover;
text-align: center;
padding: 50px;
color: red;
}
<div class="container-fluid">
<div class="row">
<div class="img-wrap">
<h1>Funny Island</h1>
<div>
<p>Some text here</p>
<button>Button here</button>
</div>
</div>
</div>
</div>
You can use a negative on themargin-bottom of the element that you wish to contain the image. This will pull the element containing your form content up and above the element with the image inside it. See below for a demo:
.image-container {
height: 50vh;
background: red;
margin-bottom: -200px;
}
.content-container {
height: 150vh;
max-width: 960px;
margin: auto;
background: blue;
}
<div class="image-container"></div>
<div class="content-container"></div>
Another option is to add top or left properties to img-wrap div to position it where you want.
.img-wrap div{
position: absolute;
width:1000px;
height: 900px;
background-color: grey;
top:100px;
left:100px;
}

Aligning text on a box

I have this flip box which looks like this
When I hover on it, it would turn around and would look like this.
I want to know, how do I move the text to the right only, I tried putting text-align: right; on my css but it didn't work. Am I doing it wrong?
Here's my CSS and HTML:
.box9 {
background-color: #4C586F;
width: 250px;
height: 150px;
margin: 0 auto;
padding: 45px;
}
.box10 {
background-image: url("../img/commended/erwin.png");
background-size: 50%;
background-repeat: no-repeat;
width: 250px;
height: 150px;
margin: 0 auto;
padding: 45px;
}
<div class="col_third">
<div class="hover panel">
<div class="front">
<div class="box9">
<p style="font-size:180%; color: white">Kudos!</p>
</div>
</div>
<div class="back">
<div class="box10">
<p style="font-size:180%; color: black">sdasdsadas</p>
</div>
</div>
</div>
</div>
I would do it like this, setting text-align: right in the back view and to center in the front view, vertical centering of the p tag and also changing some other settings (no padding [therefore changed width and height settings] and some other details):
.box9 {
background-color: #4C586F;
width: 340px;
height: 240px;
margin: 0 auto;
text-align: center;
}
.box10 {
background-image: url(http://placehold.it/150x250/);
background-size: auto 100%;
background-repeat: no-repeat;
width: 340px;
height: 240px;
margin: 0 auto;
text-align: right;
}
.box9 p,
.box10 p {
margin: 0;
position: relative;
top: 50%;
transform: translateY(-50%);
}
.box10 p {
padding-right: 20px;
}
<div class="col_third">
<div class="hover panel">
<div class="front">
<div class="box9">
<p style="font-size:180%; color: white">Kudos!</p>
</div>
</div>
<div class="back">
<div class="box10">
<p style="font-size:180%; color: black">sdasdsadas</p>
</div>
</div>
</div>
</div>

How to add a cicle in front of an image

I'm trying to add a circle (the circle will contains an icon) in front of an image. My code works fine, but only in big display; 1,224 and up..However, this is not the case for tablet and mobile...So, my question is: How can I fix my code and make it works for all devices, without using #media. If #media is the only solution, then I will go for it..
HTML
<div class="row">
<div class="col-md-3">
<div class="service-box">
<div class="service-circle" >
<!--Add icon inside circle -->
</div>
<div class="service-bg" style="background-color: black;">
<!-- Insert img-->
</div>
<div class="service-text">
<h3>
ENTER TITLE
</h3>
</div>
</div>
</div>
<div class="col-md-3">
</div>
<div class="col-md-3">
</div>
<div class="col-md-3">
</div>
</div>
CSS/LESS
.service-box {
.service-circle{
width: 120px;
height: 120px;
border-radius: 50%;
display: table-cell;
vertical-align: middle;
color: #000;
line-height: 500px;
text-align: center;
background: #fff;
position: absolute;
left: 30%;
margin-top: 65%;
border: 5px solid #e6ab43;
}
.service-bg {
height: 250px;
border:1px solid black;
img{
height: 100%;
}
}
.service-text {
text-align: center;
margin-top: 30%;
}
}
UPDATE:
This is what I'm trying to do:
Therefore, I'm using col-sm-3.
If you move your service-circle element inside your service-bg, you can then align it using transform: translate
.service-box {
background: red;
}
.service-bg {
position: relative; /* added */
height: 250px;
border:1px solid black;
}
img{
height: 100%;
}
.service-circle{
width: 120px;
height: 120px;
border-radius: 50%;
color: #000;
background: #fff;
position: absolute;
left: 50%; /* added */
top: 100%; /* added */
transform: translate(-50%,-50%); /* added */
border: 5px solid #e6ab43;
}
.service-text {
text-align: center;
margin-top: 80px; /* changed */
}
<div class="row">
<div class="col-md-3">
<div class="service-box">
<div class="service-bg" style="background-color: black;">
<!-- Insert img-->
<div class="service-circle">
<!--Add icon inside circle -->
</div>
</div>
<div class="service-text">
<h3>
ENTER TITLE
</h3>
</div>
</div>
</div>
<div class="col-md-3">
</div>
<div class="col-md-3">
</div>
<div class="col-md-3">
</div>
</div>

Floating 2 divs inside of a position relative div

I have a question about floating 2 divs inside of a position relative div. They should float left, but it does not work. I tryed it a few times by rewriting the CSS in developer tools. I hope someone can help me. I use the MDL (Material Design Lite) responsive framework from Google Inc. The result should look like in the screenshot. Thanks in advance for your help.
Final result
.card-wasserlabor {
min-height: 0;
width: 100%;
min-height: 110px;
height: auto;
box-shadow: 0 1px 1px 0 rgba(0,0,0,.015),0 3px 1px -2px rgba(0,0,0,.15),0 1px 5px 0 rgba(0,0,0,.015);
h4 {
font-size: $card-title;
color: $dark-text;
margin-left: 12px;
margin-top: 3px;
}
.img {
background: $grey;
display: inline-block;
height: 100%;
position: absolute;
width: 117px;
img {
height: 100%;
position: absolute;
width: 100%;
}
.circle-check {
background: rgba($black, 0.4);
height: 56px;
width: 56px;
border-radius: 100%;
position: absolute;
left: calc(50% - 30px);
top: calc(50% - 25px);
&:hover {
background: rgba($red, 1);
}
}
<div class="mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
<div class="mdl-card card-wasserlabor">
<div class="img">
<img src="../assets/cards/card-img-10.png" alt="sera">
<div class="circle-check">
<i class="material-icons">check</i>
</div>
</div>
<div class="text">
<h4>Mittelamerika</h4>
</div>
<div class="info">
<div class="mdl-button mdl-js-button mdl-button--icon">
<i class="material-icons">info</i>
</div>
</div>
</div>
</div>
I couldn't really run your code, there are too many missing variables to be able to work off of that. So I redid the code. I hope this can help. You just need to manage your widths and float everything left:
Take a look at this jsFiddle.
EDIT: The jsFiddle link was incorrect at first. Reclick this link if code relates to something else entirely.
EDIT 2: Fixed padding error in code. And replaced jsfiddle link.
html:
<div class="header-area">
<div style="padding: 20px; ">
Yellow header
</div>
</div>
<div class="container">
<div class="element" style="background-color: green; ">
<img src="http://placehold.it/150x150" alt="">
<div class="description">
This is the description
</div>
</div>
<div class="element" style="background-color: red; ">
<img src="http://placehold.it/150x150" alt="">
<div class="description">
This is the description
</div>
</div>
<div class="element" style="background-color: orange; ">
<img src="http://placehold.it/150x150" alt="">
<div class="description">
<div class="text">
This is the description
</div>
</div>
</div>
</div>
css:
.header-area{
background-color: yellow;
height: 100px;
width: 100%;
}
.container{
height: 100%;
width: 100%;
float: left;
background-color: lightblue;
}
.element{
float: left;
width: 50%;
height: 150px;
}
img{
float: left;
}
.description{
text-align: center;
}
.text{
padding-top: 50px;
}
I've made some modifications in your code, hope it can help you to completely achieve your goal:
To position your text over the img, you need to relative position their parent, and absolute position the text. Then you can move it over the img.
To easily align the img with the other elements, I think is useful to wrap these elements and give them an inline-block display. Then you can adjust them at the position you want.
.card-wasserlabor {
min-height: 0;
width: 100%;
min-height: 110px;
height: auto;
box-shadow: 0 1px 1px 0 rgba(0,0,0,.015),0 3px 1px -2px rgba(0,0,0,.15),0 1px 5px 0 rgba(0,0,0,.015);
}
h4 {
font-size: $card-title;
color: $dark-text;
}
.img {
background: $grey;
display: inline-block;
height: 100%;
position: relative;
width: 117px;
}
.circle-check {
position: absolute;
top: 0;
left: 0;
background: rgba($black, 0.4);
height: 56px;
width: 56px;
border-radius: 100%;
position: absolute;
left: calc(50% - 30px);
top: calc(50% - 25px);
&:hover {
background: rgba($red, 1);
}
}
.info-wrapper{
display: inline-block;
vertical-align: top;
}
<div class="mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
<div class="mdl-card card-wasserlabor">
<div class="img">
<img src="http://sweetclipart.com/multisite/sweetclipart/files/ff0000%20Color%20Square%20RGB%20Red.png" alt="sera" width="100px">
<div class="circle-check">
<i class="material-icons">check</i>
</div>
</div>
<div class="info-wrapper">
<div class="text">
<h4>Mittelamerika</h4>
</div>
<div class="info">
<div class="mdl-button mdl-js-button mdl-button--icon">
<i class="material-icons">info</i>
</div>
</div>
</div>
</div>
</div>