I have 3 boxes that in a normal desktop viewport they display in an inline fashion. My issue is when in a 640 viewport or less I cannot get the boxes to display: block; . I have tried putting the display: block in the .box class and the individual color ids. What happens is the boxes overlap and lay on each other.
Does anyone see what I am doing wrong in my attempt?
<section id="info">
<article>
<a href="projects"><div id="green" class="box">
<div class="info-box-title">PROJECTS</div>
<div class="info-box-description">Over 60 years of accumulated projects.</div>
</div></a>
<a href="about"><div id="yellow" class="box">
<div class="info-box-title">ABOUT US</div>
<div class="info-box-description">Find out about - The Eslich Wrecking Company.</div>
</div></a>
<a href="contact"><div id="red" class="box">
<div class="info-box-title">CONTACT US</div>
<div class="info-box-description">Contact us for more information.</div>
</div></a>
</article>
</section>
Default CSS
#info {
max-width: 80%;
height: auto;
padding: 100px 10%;
margin: 100px 10%;
}
.box {
width: 20%;
height: 300px;
opacity:0;
position: absolute;
line-height: 1.5em;
}
#green, #yellow, #red {
box-shadow: inset 0 0 0 0;
-webkit-transition: all ease 0.3s;
-moz-transition: all ease 0.3s;
transition: all ease 0.3s;
}
#green {
background: #3e745b;
left: 15%;
}
#yellow {
background: #6f9697;/*#f3db6d*/
left: 40%;
}
#red {
background: #3e745b;
left: 65%;
}
#green:hover, #yellow:hover, #red:hover {
/*box-shadow: inset 0 300px 0 0 #6f9697;*/
box-shadow: inset 0 300px 0 0 #303030;
}
#green.green{animation:slideinGreen .5s ease}
#yellow.yellow{animation:slideinYellow 1.3s ease}
#red.red{animation:slideinRed 2s ease}
#green.active,#red.active,#yellow.active{opacity: 1}
#keyframes slideinGreen {
from {
left: calc(25% - 250px);opacity:0;
}
}
#keyframes slideinYellow{
from {
left: calc(45% - 350px);opacity:0;
}
}
#keyframes slideinRed {
from {
left: calc(65% - 450px);opacity:0;
}
}
Media query of 640px or less
/*---Fade In Boxes---*/
#info {
max-width: 100%;
height: auto;
padding: 100px 0%;
margin: 0;
}
.box {
width: 100%;
height: 200px;
position: absolute;
line-height: 1.5em;
display: block;
}
#green {
left: 0%;
}
#yellow {
left: 0%;
}
#red {
left: 0%;
}
Your absolute positioning on the box class is causing the issue. The elements are overlapping one another because of this.
Change position of .box to relative:
#media screen and (max-width: 640px) {
.box {
width: 100%;
height: 200px;
position: relative;
line-height: 1.5em;
display: block;
}
Because #home-info-container have padding: 100px 15%, 3 boxes can full width. If you want full with for 3 boxes, and keep padding ofdescription:
#media screen and (max-width: 640px) {
#home-info-container {
padding-left: 0;
padding-right: 0;
}
#home-info-container-description {
padding-left: 15%;
padding-right: 15%;
}
}
Related
I'm trying to make an animated border for a div. I unhid the overflow of its formatting element so that I could see what the issue was. I'd like to make the center of rotation the center of the larger div.
I know I can make the center of rotation higher by setting the width and height of the before psuedoelement to that of its container, but I want to make it taller because if I set the width and height to its formatting element, it's too small and doesn't cover the edges.
I've tried using CSS positioning, but it isn't working and I have no idea why.
<div class="center">
<div class="wrapper">
<div class="directory module">
<div id="header" class="small_wrapper center">
<div class="module">
<p style="font-size: 22px">Placeholder</p>
</div>
</div>
<div class="directory_bar small_wrapper center"><div class="module">About Me</div></div>
<div class="directory_bar small_wrapper center"><div class="module">PC Builds</div></div>
<div class="directory_bar small_wrapper center"><div class="module">Original Characters</div></div>
<div class="directory_bar small_wrapper center"><div class="module">Games & Loadouts</div></div>
<div class="directory_bar small_wrapper center"><div class="module">Socials</div></div>
</div>
</div>
</div>
#charset "utf-8";
#keyframes rotate {
0% {
transform: rotate(0);
}
50% {
transform: rotate(180deg);
}
100% {
transform: rotate(360deg);
}
}
html {
font-size: 3.0vh;
}
body {
background-color: #2C2C2C;
font-family: Urbanist, sans serif;
color: white;
}
p {
margin: 0;
}
.left, .right, .center {
position: relative;
}
.center {
margin-left: auto;
margin-right: auto;
}
.module {
background-color:#2C2C2C;
text-align: center;
padding: 10px;
border-radius: 18px;
z-index: 1000;
position: relative;
}
.wrapper, .small_wrapper {
position: relative;
width: fit-content;
height: fit-content;
background: blue;
z-index: 1000;
}
.wrapper {
border-radius: 20px;
padding: 4px;
}
.wrapper::before {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: linear-gradient(to right, rgb(255, 0, 0), rgb(145,
255, 0), rgb(189, 1, 180));
animation: rotate;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-timing-function: linear;
content: '';
border-radius: 20px;
height: 1000px;
}
.small_wrapper {
padding: 3px;
}
.directory_bar {
margin-top: 5vh;
}
.directory {
padding: 5vh;
}
.center > .wrapper {
margin-left: 100px;
}
.directory_bar, #header {
border-radius: 8px;
}
.directory_bar > .module, #header > .module {
border-radius: 7px;
}
I have to create a progress bar that has to be fully responsive. In order to be responsive I don't want the progress bar class to have a fixed width, but when I put auto in width, line of progress bar is detached from the star also if I give to them auto width
Fixed width: look good
Width auto
First how can I fix this issue, and perhaps someone can help me achieve this progress bar to be responsive on mobile also so that the line of progress bar will be vertical.
.progress-bar {
width: 750px;
display: flex;
margin: 40px 0;
}
.progress-bar .step {
text-align: center;
width: 100%;
}
.progress-bar .step .bullet {
position: relative;
height: 25px;
width: 25px;
display: inline-block;
}
.progress-bar .step:last-child .bullet:before,
.progress-bar .step:last-child .bullet::after {
display: none;
}
.progress-bar .step .bullet:before,
.progress-bar .step .bullet::after {
position: absolute;
content: "";
height: 3px;
right: -136px;
bottom: 11px;
width: 142px;
background: #C1C1C1;
}
.active-bullet {
z-index: 1;
}
.active-check {
z-index: 2;
}
<div class="progress-bar">
<div class="step">
<div class="bullet active-bullet">
<img src="star-pb-active.svg">
</div>
<div class="check active-check" style="
border-bottom: 2px solid black;
padding: 2px;
DISPLAY: table-cell;
LEFT: 40px;
POSITION: relative;
">Order placed</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Jewerly Creation</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Packing & Quality Control</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Shipped</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Estimated Delivery</div>
</div>
</div>
You should try taking a look at the flex-grow property from Flexbox.
By giving display: flex to the parent, and flex-grow: 1 to the children, you should be able to make every step be the same size and take all the width of their container.
It works the way you want, in fixed or auto width.
.progress-bar {
width: auto;
display: flex;
margin: 40px 0;
}
.progress-bar .step {
text-align: center;
position: relative;
isolation: isolate;
width: 100%;
}
.progress-bar .step::after {
content: "";
position: absolute;
z-index: -1;
height: 3px;
top: 12px; /* 1/2 of .bullet's height */
width: 100%;
background: #C1C1C1;
}
.progress-bar .step:last-child::after {
display: none;
}
.progress-bar .step .bullet {
position: relative;
height: 25px;
width: 25px;
display: inline-block;
}
.active-bullet {
z-index: 1;
}
.active-check {
z-index: 2;
}
Added pseudo element on the parent of .bullet.
Also you don't need ::before, one of those pseudo elements was enough.
try below code, your code some confusion.
use flex in css
below sample add one button which goes your activity to next step
it is fully responsive - on desktop this code horizontal and on mobile this code show vertical progressbar.
just use small js, css and for tick icon font awesome js.
if any query comment it.
let step = 'step1';
const step1 = document.getElementById('step1');
const step2 = document.getElementById('step2');
const step3 = document.getElementById('step3');
const step4 = document.getElementById('step4');
function next() {
if (step === 'step1') {
step = 'step2';
step1.classList.remove("is-active");
step1.classList.add("is-complete");
step2.classList.add("is-active");
} else if (step === 'step2') {
step = 'step3';
step2.classList.remove("is-active");
step2.classList.add("is-complete");
step3.classList.add("is-active");
} else if (step === 'step3') {
step = 'step4d';
step3.classList.remove("is-active");
step3.classList.add("is-complete");
step4.classList.add("is-active");
} else if (step === 'step4d') {
step = 'complete';
step4.classList.remove("is-active");
step4.classList.add("is-complete");
} else if (step === 'complete') {
step = 'step1';
step4.classList.remove("is-complete");
step3.classList.remove("is-complete");
step2.classList.remove("is-complete");
step1.classList.remove("is-complete");
step1.classList.add("is-active");
}
}
.progress-bar {
position: relative;
display: flex;
}
.progress-bar .progress-track {
position: absolute;
top: 5px;
width: 100%;
height: 5px;
background-color: #dfe3e4;
z-index: -1;
}
.progress-bar .progress-step {
position: relative;
width: 100%;
font-size: 12px;
text-align: center;
}
.progress-bar .progress-step:last-child:after {
display: none;
}
.progress-bar .progress-step:before {
content: "\f00c";
display: flex;
margin: 0 auto;
margin-bottom: 10px;
width: 10px;
height: 10px;
background: #fff;
border: 4px solid #dfe3e4;
border-radius: 100%;
color: transparent;
}
.progress-bar .progress-step:after {
content: "";
position: absolute;
top: 6px;
left: 50%;
width: 0%;
transition: width 1s ease-in;
height: 5px;
background: #dfe3e4;
z-index: -1;
}
#media screen and (max-width:700px) {
.progress-bar {
position: relative;
display: inline-block;
}
.progress-bar .progress-track {
position: absolute;
top: -10px;
width: 100%;
height: 5px;
background-color: #dfe3e4;
z-index: -1;
transform: rotate(90deg);
}
.progress-bar .progress-step {
position: relative;
width: 100%;
font-size: 12px;
text-align: center;
}
.progress-bar .progress-step:last-child:after {
display: none;
}
.progrestext
{
left: 44px;
position: absolute;
top: 0px;
}
.progress-bar .progress-step:after {
content: "";
position: absolute;
top: 20px;
left: 0%;
width: 0%;
transition: width 1s ease-in;
height: 5px;
background: #dfe3e4;
z-index: -1;
transform: rotate(90deg);
}
}
.progress-bar .progress-step.is-active {
color: #2183dd;
}
.progress-bar .progress-step.is-active:before {
border: 4px solid #777;
animation: pulse 2s infinite;
}
.progress-bar .progress-step.is-complete {
color: #009900;
}
.progress-bar .progress-step.is-complete:before {
font-family: FontAwesome;
font-size: 10px;
color: #fff;
background: #009900;
border: 4px solid transparent;
}
.progress-bar .progress-step.is-complete:after {
background: #2183dd;
animation: nextStep 1s;
animation-fill-mode: forwards;
}
#keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(33, 131, 221, 0.8);
}
70% {
box-shadow: 0 0 0 10px rgba(33, 131, 221, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(33, 131, 221, 0);
}
}
#keyframes nextStep {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
.container {
margin: 50px 100px;
}
button {
position: absolute;
right: 50px;
bottom: 20px;
cursor: pointer;
}
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://use.fontawesome.com/c47bc38e87.js"></script>
<div class="container">
<div class="progress-bar">
<div class="progress-track"></div>
<div id="step1" class="progress-step">
<div class="progrestext">placed</div>
</div>
<div id="step2" class="progress-step">
<div class="progrestext">Creation</div>
</div>
<div id="step3" class="progress-step">
<div class="progrestext">Packing</div>
</div>
<div id="step4" class="progress-step">
<div class="progrestext">Delivered</div>
</div>
</div>
<button onClick=next()>Next Step</button>
</div>
Im a beginner for the bootstrap, some text are every where, how can i set it
Im trying to make some application its is not a working for all of mobile devices,its only working for iPhone 6+ and nexus 6p
how can i fix it??
html
<div class="progress-bar position" data-percent="48" data-duration="1000" data-color="#63676e,#ec9850"><script>$(".progress-bar").loading();</script></div>
<div id="Main">
<h2 class="text-color-header">Room Utilization</h2>
<h5 class="text-header">9 rooms occupied today</h5>
<div id="container">
<div class="block block-1">
<h1>$ 2,300</h1>
<h5>Today Revenue</h5>
</div>
<div class="block block-2">
<h1>$ 12,100</h1>
<h5>Reservation for next 15 days</h5>
</div>
<div class="block block-3">
<h1>$ 41,000</h1>
<h5>Revenue Todate / Month</h5>
</div>
<div class="block block-4">
<h1>$ 53,100</h1>
<h5>Expected Revenue for this month</h5>
</div>
<!--Menu Part 02-->
<div id="base">
<div class="base-block">
<h4>Payments</h4>
<h1>$ 2,000</h1>
<h5>5 check-outs today</h5>
</div>
<div class="base-block">
<h4>Down Payments</h4>
<h1>$ 300</h1>
<h5>2 Bokings withdown payments</h5>
</div>
</div>
<!-- End of menu Part-->
</div>
</div>
css
body{webkit-overflow-scrolling: touch;}
.text-color-header { margin-top: 250px;}
/* Progress Bar */
.progress-bar {
text-align: center;
height: 150px;
width: 150px;
margin-left: 100px;
}
.progress-bar {
float: left;
width: 0;
height: 100%;
font-size: 12px;
line-height: 20px;
color: #fff;
text-align: center;
-webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);
-webkit-transition: width .6s ease;
-o-transition: width .6s ease;
transition: width .6s ease;
}
.progress-bar div {
position: absolute;
height: 200px;
width: 200px;
border-radius: 50%;
}
.progress-bar div span {
position: absolute;
font-family: Arial;
font-size: 35px;
line-height: 175px;
height: 175px;
width: 175px;
left: 12.5px;
top: 12.5px;
text-align:center;
border-radius: 50%;
background-color:#e0e0e0;
color: black;
}
.progress-bar .background {
background-color: #b3cef6;
}
.progress-bar .rotate {
clip: rect(0 100px 200px 0);
background-color: #4b86db;
}
.progress-bar .left {
clip: rect(0 100px 200px 0);
opacity: 1;
background-color: #b3cef6;
}
.progress-bar .right {
clip: rect(0 100px 200px 0);
transform: rotate(180deg);
opacity: 0;
background-color: #4b86db;
}
#keyframes toggle {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
/*End of Progress Bar*/
.page {
margin: 0px auto;
display: flex;
}
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
.clearfix {
display: inline-block;
margin: 0px auto;
}
h5,
.h5 {
font-size: 13px;
text-align: center;
}
.block {
width: 200px;
height: 100px;
margin: 1px;
display: inline-block;
background: ;
color: #d4c4b6;
}
.block:hover h1 {
color: #000000;
}
.block:hover h5 {
color: #A48973;
}
#base {
background: #e2e2e2;
display: inline-block;
height: 120px;
margin-left: 0px;
margin-top: -7px;
position: relative;
width: auto;
}
#base:before {
border-bottom: 35px solid #e2e2e2;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
content: "";
height: 0;
left: 173px;
position: absolute;
top: -20px;
width: 0;
}
h1,
.h1 {
font-size: 27px;
text-align: center;
}
h2,
.h2 {
font-size: 20px;
text-align: center;
}
h4,
.h4 {
font-size: 16px;
text-align: center;
}
.base-block {
display: inline-block;
height: 120px;
width: 200px;
margin: 1px;
display: inline-block;
}
.base-block h1,
h4 {
color: #000000;
}
.base-block h5 {
color: #A48973;
}
.navbar-default .navbar-brand {
color: #A48973;
}
.navbar-default .navbar-toggle {
border: none;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: #A48973;
}
.search-bar {
padding: 7px 15px;
}
/*Start Media query*/
#media (max-width: 768px) {
.form-control {
padding: 6px 100px;
}
}
/*End Of Media query*/
Use bootstrap grid layout classes col-xs-6 for div's instead of block-1, block-2. In your css, set width and height in percentages instead of numbers in px.
Also, try not to set height, instead set width.
Use classes like panel and panel-body in each div.
Put entire content in
<div class="container-fluid">
//Create three rows
<div class="row">
//create 2 divs with class col-xs-6
</div>
<div class="row">
//create 2 divs with class col-xs-6
</div>
<div class="row">
//create 2 divs with class col-xs-6
</div>
</div>
I couldn't add a comment so I'll just compound with Amit's answer. Make sure this
<meta name="viewport" content="width=device-width, initial-scale=1" /> is in your head tags as well. It set you page viewport size to the px size of device. Without it the code Amit suggested won't work. All in all your not actually using any Bootstrap in your code. I would also recommend looking through this to get a true understanding of Bootstrap https://www.w3schools.com/bootstrap
Currently, I have a website where images are clashing with the text over it.
I'm new to HTML/CSS and have looked around online but haven't ha dmuch luck. Basically, when a user isn't hovered over a box, an image should show a bit faded with text on top. When the use is hovered over the box, the image should be?
.showcase {
overflow: hidden;
margin-left: -1px;
#include flexbox;
#include justify-content(center);
}
.custom_showcase {
position: relative;
padding: 1px 0 0 1px;
#include flexbox;
img {
width: 100%;
max-width: none;
}
.inside {
display: inline-block;
max-width: 100%;
width: 100%;
background: $color_1;
#include flexbox;
#include align-items(center);
}
.textblock {
padding: 20px;
}
img + .textblock {
position: absolute;
left: 50%;
top: 50%;
width: 100%;
max-width: 455px;
padding: 0 20px;
color: $color_3;
#include transform(translate(-50%,-50%));
}
h2 {
color: $color_3;
margin: 16px 0 5px;
text-transform: uppercase;
}
p {
margin: 0;
color: $color_3;
}
h2,
p {
span {
display: inline-block;
padding-left: 0;
#include transition(.4s);
}
}
.text {
width: 100%;
}
.btn_wrapper {
position: absolute;
right: 40px;
top: 50%;
#include transform(translate(0%,-50%));
.btn {
padding: 0 10px;
min-width: 140px;
text-align: center;
opacity: 0;
#include transition(.4s);
#include transform(translate(100%,0%));
/* border-color: $color_3; */
}
}
a:not(:hover) {
//h2,
//p {
// span {
// padding-right: 0 !important;
// }
//}
opacity: .5;
transition: opacity 0.5s ease;
}
a:hover {
h2,
p {
span {
padding-left: 0 !important;
}
}
.btn_wrapper {
.btn {
opacity: 1;
#include transform(translate(0%,0%));
}
}
}
This is the best I could do with the info you have provided.
Hopefully it is helpful to you.
#theBox {
width: 200px;
height: 200px;
border: 2px solid black;
}
#octocat {
width: 185px;
opacity: 0;
}
#octocat:hover {
opacity: 1;
}
<div id="theBox">
<center>
<span> Mr. Octocat right down here. </span>
<br>
<img id="octocat" src="https://upload.wikimedia.org/wikipedia/commons/9/91/Octicons-mark-github.svg">
</center>
</div>
I'm not sure of those classes, but considering the description of your problem, here's what you can probably do:-
.image-class {
opacity: 0.4;
/*This is optional*/transition: opacity 0.5s;
}
.image-class:hover {
opacity: 1;
}
Hope that helps :)
Please correct me if I misunderstood your point.
One possible solution is to set the image as the background of a div, then nest another div inside of it that matches the width and height of the image div.
Add a background color with opacity to that inside div, and your text, then set it to invisible when hovered over.
.img-box {
background: url('http://sierranewsonline.com/wp-content/uploads/2016/07/Virginia-Eaton-July-2-SNOL-Nightshade-lycianthes-rantonnetii-10404.jpg');
background-position: top center;
width: 350px;
height: 350px;
}
.text-overlay {
width: 100%;
height: 100%;
background-color: rgba(255,255,255,0.5);
text-align: center;
}
.text-overlay:hover {
opacity: 0;
}
.text-centered {
display: inline-block;
font-size: 16px;
font-weight: bold;
padding-top: 32px;
}
<div class="img-box">
<div class="text-overlay">
<span class="text-centered">Hover over the Image</span>
</div>
</div>
Try this:
#box {
width: 300px;
position: relative;
}
.imgDiv {
margin: 0;
opacity:0.2;
}
.imgDiv:hover {
opacity:1;
}
img {
width: 100%
}
span {
position: absolute;
color:#fff;
bottom: 10px;
background: #000;
}
<div id="box">
<span>Cute Animal</span>
<div class="imgDiv">
<img src="http://www.mrwallpaper.com/wallpapers/cute-bunny-1600x900.jpg">
</div>
</div>
You can nest the text in an element that wraps the image, then on :hover alter the opacity of the image and the text to hide/show.
.card {
display: inline-block;
position: relative;
}
.info {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 2.5em;
opacity: 0;
}
.card:hover .info {
opacity: 1;
}
.card:hover img {
opacity: .5;
}
img {
vertical-align: top;
max-width: 300px;
}
.info, img {
transition: opacity .25s;
}
<div class="card">
<img src="http://kenwheeler.github.io/slick/img/fonz1.png">
<div class="info">some text</div>
</div>
<div class="card">
<img src="http://kenwheeler.github.io/slick/img/fonz1.png">
<div class="info">some text</div>
</div>
<div class="card">
<img src="http://kenwheeler.github.io/slick/img/fonz1.png">
<div class="info">some text</div>
</div>
IMPORTANT NOTE: only CSS/HTML, but not javascript (client does not allow it)
recently started the homepage of my site and wanted to make a centrally divided layout. Want to place the logo on the middle and one picture on top of it with a button to lead to the page, and one below it with the same function.
The animation should be a hover over the buttons (or defined area around it) as seen in the comp I did here:
GIF ANIMATION OF WHAT IS INTENDED
Similar to what is intended: https://jsfiddle.net/vja85zgL/
* {
margin: 0px;
padding: 0px;
}
#wrapper {
width: 80%;
height: 200px;
margin: auto;
}
#wrapper:hover #left:not(:hover) {
width: 25%;
transition: width 1s linear;
}
#wrapper:hover #right:not(:hover) {
width: 25%;
transition: width 1s linear;
}
#left {
width: 50%;
height: 100%;
background-color: lightblue;
display: inline-block;
position: relative;
transition: width 1s linear;
}
#innerleft {
position: absolute;
top: 100px;
width: calc(100% - 4px);
text-align: center;
border: 2px solid black;
}
#right {
width: 50%;
height: 100%;
background-color: lightgrey;
display: inline-block;
position: relative;
transition: width 1s linear;
}
#innerright {
position: absolute;
top: 100px;
width: calc(100% - 4px);
text-align: center;
border: 2px solid black;
}
#right:hover {
width: 75%;
transition: width 1s linear;
}
#left:hover {
width: 75%;
transition: width 1s linear;
}
<div id="wrapper">
<div id="left">
<div id="innerleft">
TITLE 1
</div>
</div><div id="right">
<div id="innerright">
TITLE 2
</div>
</div>
</div>
As seen, if hovering over the button, the background image behind the button shows itself "fully" (no rescaling), the logo (showed as B) moves down to 25% and the button not hovered scales down in size and font size and the image behind it slides under it where the user cannot see it properly (the user cannot see it by scrolling down).
If hovered on the other button the animation goes to the other button and image background.
There should be a delay of 2 seconds before the layout comes back to the starting position
DETAILS:
NO JAVASCRIPT ALLOWED, client doesn't allow usage
Should be responsive, so no hovering on touch devices
The image must not resize or loose proportion
Full screen layout
Mouse simulates user.
Animation should return to initial position after 3 seconds if mouse is not hovering
Initial position is 50%-50% (almost, due to the logo which is 150x150px)
End position should be 75%-25%.
Have been loosing my mind the last 2 days wondering how to do it as I am a beginner at CSS but didn't find a way yet.
Any help would be appreciated!
Available code of what has been done already to the design (total mess...):
#business-top {
height:50%
width:100%
}
#business-button {
height:3em;
width:12em;
background-color:#2B2A2A;
border: .2em solid #ff7600;
border-radius:1.8em;
margin:auto;
margin-top:3em;
}
#logo-separator {
text-align:center;
}
.separator {
display: block;
position: relative;
padding: 0;
height: 0;
width: 100%;
max-height: 0;
font-size: 1px;
line-height: 0;
clear: both;
border: none;
border-top: 1px solid #ff7600;
border-bottom: 1px solid #ff7600;
}
#logo {
margin:auto;
max-width:150px;
display:inline-block;
overflow:hidden
margin-top:-75px
}
#photography-bottom {
height:50%
width:100%
}
#photography-button {
height:3em;
width:12em;
background-color:#2B2A2A;
border: .2em solid #ff7600;
border-radius:1.8em;
margin:auto;
margin-top:3em;
}
h1 {
color:#ff7600;
text-align:center;
font-size:1.4em;
vertical-align:middle;
line-height:2.2em
}
<div id="business-top"
<a href="www.lluisballbe.smugmug.com">
<div id="business-button">
<h1>BUSINESS</h1>
</div>
</a>
</div>
<div id="logo-separator">
<div class="separator"></div>
<div id="logo"><img src="https://lluisballbe.smugmug.com/Assets-for-website/i-CsMnM3R/0/Th/800x800-round-Th.png"</div>
</div>
<div id="photography-bottom"
<a href="www.lluisballbe.smugmug.com">
<div id="photography-button">
<h1>PHOTOGRAPHY</h1>
</div>
</a>
</div>
If you increase area of buttons once hovered , then you may have some results in CSS only:
trick comes from pointer-events and pseudo to increase hoverable area
/* tricky part */
div {
width: 100%;
pointer-events: none;
overflow: hidden;
transition: 1.5s;
}
div:hover {/* will be catch by child with pointer-events auto */
flex: 3;
}
div:first-child {
background: turquoise;
}
div a {
pointer-events: auto;/* if a is hovered, so is its parent */
position: relative;/* this could be for the div parent if you want to cover its area */
padding: 5px;
border-radius: 0.25em;
border: 3px solid;
box-shadow: 2px 2px 5px;
color: #222;
background: #aaa;
}
div a:hover:before {/* increase size of button only once hovered */
content: '';
position: absolute;
top: -200px;/* coordonates used to increase pseudo size from its relative position parent. tune to your needs */
bottom: -200px;
width: 100%;
}
/* layout */
body,
div {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
div {
flex: 1;
}
hr {
width: 100%;
height: 5px;
background: red;
text-align: center;
}
hr:before {
content: url(http://dummyimage.com/50x50);
display: inline-block;
height: 50px;
border-radius: 50%;
overflow: hidden;
margin-top: -25px;
}
html,
body {
height: 100%;
width: 100%;
margin: 0;
}
<div>
button style
</div>
<hr/>
<div>
button style
</div>
From your update snippet :
html,
body {
height: 100%;
width: 100%;
margin: 0;
}
body {
display: flex;
flex-direction: column;
}
h1 {
margin: 0;
}
a {
display: inline-block;
}
#business-top {
display: flex;
flex: 1;
width: 100%;
align-items: center;
justify-content: center;
text-align: center;
}
#business-button {
height: 3em;
width: 12em;
background-color: #2B2A2A;
border: .2em solid #ff7600;
border-radius: 1.8em;
margin: auto;
}
#logo-separator {
text-align: center;
}
.separator {
display: block;
position: relative;
padding: 0;
height: 0;
width: 100%;
max-height: 0;
font-size: 1px;
line-height: 0;
flex: 0;
border-top: 1px solid #ff7600;
border-bottom: 1px solid #ff7600;
}
#logo {
margin: auto;
max-width: 150px;
display: inline-block;
overflow: hidden;
margin: -75px;
position: absolute;
}
#photography-bottom {
display: flex;
flex: 1;
width: 100%;
align-items: center;
justify-content: center;
}
#photography-button {
height: 3em;
width: 12em;
background-color: #2B2A2A;
border: .2em solid #ff7600;
border-radius: 1.8em;
margin: auto;
}
h1 {
color: #ff7600;
text-align: center;
font-size: 1.4em;
vertical-align: middle;
line-height: 2.2em
}
#business-top,
#photography-bottom {
pointer-events: none;
position: relative;
z-index: 1;
transition: 1s;
/* min-height: 200px; you ma want this to avoid logo and button to overlap */
}
#business-top a,
#photography-bottom a {
pointer-events: auto;
}
#business-top:hover,
#photography-bottom:hover {
flex: 3;
}
#business-top a:hover:before,
#photography-bottom a:hover:before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
<div id="business-top">
<a href="www.lluisballbe.smugmug.com">
<div id="business-button">
<h1>BUSINESS</h1>
</div>
</a>
</div>
<div id="logo-separator">
<div class="separator"></div>
<div id="logo"><img src="https://lluisballbe.smugmug.com/Assets-for-website/i-CsMnM3R/0/Th/800x800-round-Th.png"> </div>
</div>
<div id="photography-bottom">
<a href="www.lluisballbe.smugmug.com">
<div id="photography-button">
<h1>PHOTOGRAPHY</h1>
</div>
</a>
</div>
http://codepen.io/anon/pen/qbvgga