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>
Related
I have a problem with an image and 'float: right;'. It moves everything on the image.
I really need help. I am just a beginner. Any help will be appreciated. Please help me.
My HTML code:
<section id="header">
<div class="container">
<img scr="./img/logo.png" class="logo">
<div class="header-text">
<h1>Choose the cheapest teachers</h1>
<span class="square"></span>
<p>Here you can find the best people<br>Start working for us right now</p>
<button class="common-btn">Read more</button>
</div>
</div>
My CSS code:
* {
margin: 0;
padding: 0;
font-family: sans-serif;
font: Nunito;
}
#header {
height: 100vh;
background-image: url(img/image3.png);
background-position: center;
background-size: cover;
width: 80vh;
height: 80vh;
padding:35px;
float: right;
}
}
.conatiner {
margin-right: 100px;
margin-left: 100px;
}
.logo {
margin-top: 30px;
width: 100px;
}
.header-text{
max-width: 350px;
margin-top: 140px;
}
* {
margin: 0;
padding: 0;
font-family: sans-serif;
font: Nunito;
}
#header {
height: 100vh;
background-image: url(img/image3.png);
background-position: center;
background-size: cover;
width: 80%;
height: 80vh;
padding:35px;
}
img.logo{
float: right!important;
}
.container {
margin:0;
width:100%;
}
.logo {
margin-top: 30px;
width: 100px;
}
.header-text{
max-width: 350px;
margin-top: 140px;
}
<section id="header">
<div class="container">
<img src="https://placekitten.com/200/200" class="logo">
<div class="header-text">
<h1>Choose the cheapest teachers</h1>
<span class="square"></span>
<p>Here you can find the best people<br>Start working for us right now</p>
<button class="common-btn">Read more</button>
</div>
</div>
</section>
Modify your css file to match the following
.logo {
margin-top: 30px;
width: 100px;
height: 100px; /* Add a fixed height on image */
float: right; /* then you can now float right */
}
I know this is a commonly answered question, but for some reason nothing I've tried has worked from the other Stackoverflow posts. I'm trying to have two sidebars on my website with one on each side of the main content.
I've tried using float right and float left. Block vs. inline-block etc... I'm not sure whether the the main contents should float or not. I'm using the latest google chrome browser.
HTML:
<!-- Main Page Contents -->
<div id="contents">
<div id="sidebar">
<div><p>link 1</p></div>
</div>
<div id="sidebar2">
<div><p>link 2</p></div>
</div>
<div id="mainContents">
<div class="center-div" style="width: 700px;">
<h1">This is some content</h1>
</div>
<div class="center-div" style="width: 900px;">
<h1>More content</h1>
</div>
</div>
</div>
CSS:
.center-div
{
margin: 0 auto;
padding: 15px;
background-color: red;
}
#contents {
overflow: auto;
margin: auto;
margin-bottom: 10px;
width: 100%;
}
#sidebar {
position: fixed;
float: left;
width: 200;
margin: 5px;
margin-left: 15px;
padding: 5px;
top: 46px;
margin-top: 20px;
}
#sidebar2 {
position: fixed;
float: right;
width: 50px;
margin: 5px;
padding: 5px;
top: 46px;
margin-top: 20px;
}
#mainContents {
float: right;
width: calc(100% - 300px);
margin: 0px;
padding: 5px;
padding-top: 20px;
}
Both the sidebars appear on the left side in the same position. The best I've gotten is the sidebar2 floats right of the sidebar and the contents float right of that.
You can do this using flexbox here is the working fiddle:
and also i have removed unnecessary css.
.center-div
{
margin: 0 auto;
padding: 15px;
background-color: red;
}
#contents {
overflow: auto;
margin: auto;
margin-bottom: 10px;
width: 100%;
display:flex;
}
#sidebar {
width: 20%;
margin: 5px;
padding: 5px;
margin-top: 20px;
}
#sidebar2 {
width: 20%;
padding: 5px;
margin-top: 20px;
}
#mainContents {
width: 60%;
margin: 0px;
padding-top: 20px;
}
<!-- Main Page Contents -->
<div id="contents">
<div id="sidebar">
<div><p>link 1</p></div>
</div>
<div id="mainContents">
<div class="center-div">
<h1>This is some content</h1>
</div>
<div class="center-div" >
<h1>More content</h1>
</div>
</div>
<div id="sidebar2">
<div><p>link 2</p></div>
</div>
</div>
Note: there is mistakes in html and css which i have corrected:
your code is almost correct just remove position:fixed and give proper width considering your screen as 100%
.center-div
{
margin: 0 auto;
padding: 15px;
background-color: red;
}
#contents {
overflow: auto;
margin: auto;
margin-bottom: 10px;
width: 100%;
}
#sidebar {
float: left;
width: 15%;
margin:1%;
padding: 5px;
margin-top: 20px;
}
#sidebar2 {
float:right;
width: 15%;
margin: 1%;
padding: 5px;
top: 46px;
margin-top: 20px;
}
#mainContents {
float: left;
width:59%;
margin: 0px;
padding: 5px;
padding-top: 20px;
}
<!-- Main Page Contents -->
<div id="contents">
<div id="sidebar">
<div><p>link 1</p></div>
</div>
<div id="mainContents">
<div class="center-div" >
<h1>This is some content</h1>
</div>
<div class="center-div" >
<h1>More content</h1>
</div>
</div>
<div id="sidebar2">
<div><p>link 2</p></div>
</div>
</div>
I have a fixed header and a image below the header.
The image has a property position: fixed.
Now for some devices the image is not in the center as It should be.
Here's the fiddle for it.
The left side has more spaces than the right hand side.
Also above the image, I want to add a p tag which is not showing up for some reason.
Please let me know what's wrong here.
<div class="content-wrapper new-class">
<div class="container">
<div class="row">
<div class="col-xs-12 ">
<div class="center-logo description">
<img src="http://i.imgur.com/ECTLTbK.png" alt="" class="img-responsive">
<P class="step1description" See price</p>
</div>
</div>
</div>
</div>
</div>
Checkout this solution:
body, html {
margin:0;
padding:0;
}
.content-wrapper {
position: relative;
overflow: hidden;
width: 100%;
background-color: #333230;
}
.content-wrapper .center-logo {
position: fixed;
width: 100%;
top: 125px;
left:0;
text-align: center;
margin: 5px 0 15px;
z-index: 1001;
background-color: #333230;
}
.content-wrapper .center-logo img {
margin: 0 auto;
}
.center-logo p.step1description {
position: relative;
top: -30px;
width: 220px;
text-align: center;
color: #fff;
font-size: 12px;
margin: 0 auto;
}
.description {
margin:30px 0 30px 0 !important;
}
.content-wrapper .content {
text-align: center;
width: 100%;
}
.new-class{
padding-bottom: 134px;
top: 134px;
}
<div class="content-wrapper new-class">
<div class="container">
<div class="row">
<div class="col-xs-12 ">
<div class="center-logo description">
<img src="http://i.imgur.com/ECTLTbK.png" alt="" class="img-responsive">
<p class="step1description"> See price</p>
</div>
</div>
</div>
</div>
</div>
You have some typos on html and css! - Here you can find a working fiddle: http://jsfiddle.net/sebastianbrosch/cxumhp9k/1/
Add left:0 on .content-wrapper .center-logo
.content-wrapper .center-logo { left:0;}
I have the following code:
<div class="mobileTabsNavSub brClear">
<div class="mbBtnLeftMW mbBtnLeftStyle floatLeft">
</div>
<div class="mbBtnRightMW mbBtnRightStyle floatRight">
</div>
<div class="mBtnMidMW mBtnMidStyle">
<div>
<img id="mbMW1" src="icon.png" class="mBtnIcon" />
</div>
<div>
<span id="mbMW" class="mbBtnText">Services</span>
</div>
</div>
</div>
CSS:
.mobileTabsNav
{
display: none;
width: 100%;
overflow: hidden;
margin: 10px 0 10px 0;
}
.mobileTabsNavSub
{
width: 100%;
padding: 0 0 10px 0;
}
.mbBtnLeftMW
{
background: url('../theImages/mbMWLeft.png') no-repeat;
}
.mbBtnRightMW
{
background: url('../theImages/mbMWRight.png') no-repeat;
}
.mBtnMidMW
{
background: url('../theImages/mbMWMiddle.png');
}
.mbBtnLeftStyle
{
min-height: 50px;
max-height: 50px;
width: 10px;
background-size: contain;
}
.mbBtnRightStyle
{
min-height: 50px;
max-height: 50px;
width: 10px;
background-size: contain;
}
.mBtnMidStyle
{
overflow: hidden;
min-height: 50px;
max-height: 50px;
background-size: contain;
margin: 0 0px 0 8px;
text-align: center;
vertical-align: middle;
line-height: 40px;
}
.floatLeft
{
float: left;
}
.floatRight
{
float: right;
}
Output on most screen size:
Out on some screen size:
Three images:
Please help to get rid of the white space on some of those devices.
You can try adding comments to "link" the divs and remove any white space (not sure if it works in your case because of the float position)
<div class="mobileTabsNavSub brClear">
<div class="mbBtnLeftMW mbBtnLeftStyle floatLeft"></div><!--
--><div class="mbBtnRightMW mbBtnRightStyle floatRight"></div><!--
--><div class="mBtnMidMW mBtnMidStyle">
<div>
<img id="mbMW1" src="icon.png" class="mBtnIcon" />
</div>
<div>
<span id="mbMW" class="mbBtnText">Services</span>
</div>
</div>
I'm trying to create three buttons on either side of my main logo. These buttons should appear vertically center however when applying different display properties and/or margins and padding of 24px~ nothing changes. The attached JSFiddle shows the issue I have.
http://jsfiddle.net/LRaJy/
.header {
width: 100%;
background-color: #64767f;
background-position: bottom;
padding: 10px 0;
}
.header .logo {
background-image: url('../img/header-logo.png');
display:inline-block;
width: 415px;
height: 100px;
background: #fff;
}
.header-container {
width: 733px;
height: 100px;
margin: 0 auto;
}
.hover-buttons {
height: 44px;
display: inline-block;
padding-top: -5px;
}
.hover-buttons .button {
width: 44px;
height: 44px;
display: inline-block;
margin-right: 5px;
background: #fff;
}
with the HTML
<div class="header">
<div class="header-container">
<div class="hover-buttons">
<div class="button backups"></div>
<div class="button currency"></div>
<div class="button contact"></div>
</div>
<div class="logo">
</div>
<div class="hover-buttons">
<div class="button satisfaction"></div>
<div class="button security"></div>
<div class="button care"></div>
</div>
</div>
</div>
Is this what you're looking for?
jsFiddle Demo
.button, .logo {
vertical-align: middle;
}