I'm trying to build a responsive template with bootstrap 4 where there are three cards involved inside a container div. When changing the aspect ratio in mobile view, the cards are coming out of the container div and overlapping to the footer element outside it's container. Check my code below:
HTML:
<div class="container-fluid parallax">
<div class="d-flex justify-content-center">
<h1 class="title"><strong>Our Services</strong></h1>
</div>
<div class="parallax-row row justify-content-center">
<div class="parallax-cell col-sm-3">
<div class="hovereffect">
<img class="img-responsive" src="assets/images/web_dev_service.jpg" alt="" width="350" height="200">
<div class="overlay">
<h2>header</h2>
<a class="info" href="#">Know More</a>
</div>
</div>
</div>
<div class="parallax-cell col-sm-3">
<div class="hovereffect">
<img class="img-responsive" src="assets/images/digital_marketing_service.jpg" alt="" width="350" height="200">
<div class="overlay">
<h2>header</h2>
<a class="info" href="#">Know More</a>
</div>
</div>
</div>
<div class="parallax-cell col-sm-3">
<div class="hovereffect">
<img class="img-responsive" src="assets/images/creative_logo_service.jpg" alt="" width="350" height="200">
<div class="overlay">
<h2>header</h2>
<a class="info" href="#">Know More</a>
</div>
</div>
</div>
</div>
</div>
CSS:
.parallax {
background-image: url("/assets/images/home_services.jpg");
min-height: 700px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-color: #ff0;
position: relative;
}
.parallax-row {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
}
.parallax-cell {
align-self: center;
}
.hovereffect {
width: 100%;
height: 100%;
float: left;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
border-radius: 5%;
}
.hovereffect .overlay {
width: 100%;
height: 100%;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
opacity: 0;
background-color: rgba(0, 0, 0, 0.5);
-webkit-transition: all .4s ease-in-out;
transition: all .4s ease-in-out
}
.hovereffect img {
display: block;
position: relative;
-webkit-transition: all .4s linear;
transition: all .4s linear;
background-color: #f00;
}
.hovereffect h2 {
text-transform: uppercase;
color: #fff;
text-align: center;
position: relative;
font-size: 17px;
background: rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(-100px);
-ms-transform: translatey(-100px);
transform: translatey(-100px);
-webkit-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
padding: 10px;
}
.hovereffect a.info {
text-decoration: none;
display: inline-block;
text-transform: uppercase;
color: #fff;
border: 1px solid #fff;
background-color: transparent;
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
margin: 50px 0 0;
padding: 7px 14px;
}
.hovereffect a.info:hover {
box-shadow: 0 0 5px #fff;
}
.hovereffect:hover img {
-ms-transform: scale(1.2);
-webkit-transform: scale(1.2);
transform: scale(1.2);
}
.hovereffect:hover .overlay {
opacity: 1;
filter: alpha(opacity=100);
}
.hovereffect:hover h2,
.hovereffect:hover a.info {
opacity: 1;
filter: alpha(opacity=100);
-ms-transform: translatey(0);
-webkit-transform: translatey(0);
transform: translatey(0);
}
.hovereffect:hover a.info {
-webkit-transition-delay: .2s;
transition-delay: .2s;
}
Just do two things.
Replace .parallax-row with below.
.parallax-row {
display: flex;
justify-content: center;
align-items: center;
}
Replace .parallax-cell with below.
.parallax-cell {
align-self: center;
margin-bottom: 20px;
}
Here is running JSFiddle - https://jsfiddle.net/t4qfvmkr/
just need to change the property min-height to height: 100% in parallax class
Almost at the bottom of the page you see 4 images with a button inside of each image. (Verona, Mono Silk, Fibre Silk and Akvarell).
I'm trying to achieve an image, with a centered (both veritically and horizontally) text inside of it. And it all needs to be responsive.
The most important thing that I need to fix with these buttons though is that when you hover over a button, I want the image to become darker (just like it is now) but I want it to stay that way even when you hold the mouse over the text inside. I don't understand which approach I need to have to achieve that.
The html code for a button is:
.product-container {
position:relative;
background-color: #000000;
}
.product-btn {
position: absolute;
top:39%;
left: 0;
right: 0;
margin: 0 auto;
background-color: rgba(0,0,0, 0.3);
width: 50%;
border: 1px solid #e1e1e1;
color: #ffffff;
padding: 5px 0;
}
.product-img {
width:100%;
height: auto;
opacity: 1;
transition:
opacity 0.1s ease-in-out;
-moz-transition: opacity 0.1s ease-in-out;
-webkit-transition: opacity 0.1s ease-in-out;
}
.product-img:hover {opacity: 0.5;}
<div class="product-container">
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg"/>
<a href="http://google.se">
<p class="product-btn">Mono Silk</p>
</a>
</div>
How can I achieve this?
To have the image darker when hover both image and text, I changed this CSS rule
.product-img:hover {opacity: 0.5;}
to this
.product-container:hover img {opacity: 0.5;}
You also had an extra closing </div> tag which I removed.
Having block level (p) element inside an inline (a) is invalid, so I changed your p to a span and added text-align: center; to its CSS rule so the text inside is centered.
Having block level element, like p, inside an inline element is in general invalid, though according to the new HTML5 specs, an a now can have block level elements inside (Thanks to #tjameswhite pointing that out), as long as there is no interactive content within (e.g. buttons or other links).
Sample snippet
.product-container {
position:relative;
background-color: #000000;
}
.product-btn {
position: absolute;
top:39%;
left: 0;
right: 0;
margin: 0 auto;
background-color: rgba(0,0,0, 0.3);
width: 50%;
border: 1px solid #e1e1e1;
color: #ffffff;
padding: 5px 0;
text-align: center;
}
.product-img {
width:100%;
height: auto;
opacity: 1;
transition:
opacity 0.1s ease-in-out;
-moz-transition: opacity 0.1s ease-in-out;
-webkit-transition: opacity 0.1s ease-in-out;
}
.product-container:hover img {opacity: 0.5;}
<div class="product-container">
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg">
<a href="http://google.se">
<span class="product-btn">Mono Silk</span>
</a>
</div>
Change the Markup so that image comes after the link.
Then css will get the link to be in center of parent:
.product-container {
position:relative;
background-color: #000000;
}
.product-btn {
position: absolute;
top:50%;
left: 50%;
background-color: rgba(0,0,0, 0.3);
width: 50%;
border: 1px solid #e1e1e1;
color: #ffffff;
padding: 5px 0;
transform: translate(-50%, -50%);
}
.product-img {
width:100%;
height: auto;
opacity: 1;
transition:
opacity 0.1s ease-in-out;
-moz-transition: opacity 0.1s ease-in-out;
-webkit-transition: opacity 0.1s ease-in-out;
}
.product-container > a:hover + img {opacity: 0.5;}
<div class="product-container">
<a href="http://google.se">
<p class="product-btn">Mono Silk</p>
</a>
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg"></div>
</div>
In CSS (slow the style change in product-container and make hover action for it):
.product-container {position:relative; background-color: #000000;
transition: opacity 0.1s ease-in-out;
-moz-transition: opacity 0.1s ease-in-out;
-webkit-transition: opacity 0.1s ease-in-out;
}
/*.product-img:hover {opacity: 0.5;}*/
.product-container:hover img {opacity: 0.5;}
In HTML (put link inside the .product-container div):
<div class="product-container"><img class="product-img" src="./Material _ ProFormat AB_files/monosilk.jpg"/><p class="product-btn">Mono Silk</p></div>
Adjust the markup so the image and text are inside of the link:
<div class="col-sm-3 text-center">
<a href="http://google.se" class="product-container">
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg" alt="">
<div class="product-btn">Mono Silk</div>
</a>
</div>
This removes an extra container (moving the product-container class to the link). Then update styles to something like:
.product-container {
position:relative;
background-color: #000000;
display: block;
height: 426px;
width: 426px;
}
.product-img {
width: 426px;
height: 426px;
}
.product-btn {
position: absolute;
top: 39%;
left: 0;
right: 0;
margin: 0 auto;
background-color: rgba(0,0,0, 0.3);
width: 50%;
border: 1px solid #e1e1e1;
color: #ffffff;
padding: 5px 0;
text-align: center;
}
.product-container:hover .product-img {opacity: 0.5;}
.product-container:hover .product-btn {background: rgba(0,0,0,1)}
Note that the link (.product-container) has display: block; and a set width and height, as does the image. Adjust as needed.
The advantage to this is that the entire box is now one big clickable button.
A cool trick is using pseudo elements to vertically align inline blocks. This allows for multiple lines of text to also be aligned properly.
I apologise as I'm at work at the moment, so I hope this fiddle helps.
Will go into more detail in an update later if requested:
https://jsfiddle.net/pj5p0s3s/
/*Disgusting stuff for demo :) */
.product-container {
float:left;
margin-right:5px;
max-width:200px;
}
/* */
.product-container {
position:relative;
background-color: #000000;
}
.product-container a {
display:block;
}
.product-container a:after {
content:"";
background: rgba(0,0,0, 0.3);
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
}
.product-container a:hover:after {
background: rgba(0,0,0,0.6);
transition: 0.3s;
}
.product-container-overlay {
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
text-align:center;
z-index:1;
}
.product-container-overlay:before {
content:"";
height:100%;
display:inline-block;
width:1px;
vertical-align:middle;
}
.product-btn {
background-color: rgba(0,0,0, 0.3);
width: 50%;
border: 1px solid #e1e1e1;
color: #ffffff;
padding: 5px 0;
display:inline-block;
vertical-align:middle;
}
.product-img {
width:100%;
height: auto;
display:block;
}
.product-img:hover {
opacity: 0.5;
}
<div class="product-container">
<a href="http://google.se">
<div class="product-container-overlay">
<p class="product-btn">Mono Silk</p>
</div>
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg"/>
</a>
</div>
<div class="product-container">
<a href="http://google.se">
<div class="product-container-overlay">
<p class="product-btn">Mono Silk long title lipsum</p>
</div>
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg"/>
</a>
</div>
<div class="product-container">
<a href="http://google.se">
<div class="product-container-overlay">
<p class="product-btn">Mono Silk</p>
</div>
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg"/>
</a>
</div>
I'm trying to put these 4 cells together and it's not working on Chrome (it used to work before, haven't changed it), but it's working on Firefox. There is space between the cells in a row when I'm using Chrome. This shouldn't happen. This is the page I'm talking about: http://pablotv.me/chetochine/novosite/pt/marketing-research/
(Unfortunately, I can't post images because of my reputation on StackOverflow, I've just signed up and I'm an amateur yet)
Here's the HTML:
<div id="mktwrapper">
<div class="row">
<div id="box-1" class="box">
<img id="image-1" src="1.png"/>
<span class="caption full-caption">
<p>Content1</p>
</span>
</div>
<div id="box-2" class="box">
<img id="image-2" src="2.png"/>
<span class="caption full-caption">
<p>Content2</p>
</span>
</div>
</div>
<div class="row">
<div id="box-3" class="box">
<img id="image-3" src="3.png"/>
<span class="caption full-caption">
<p>Content3</p>
</span>
</div>
<div id="box-4" class="box">
<img id="image-4" src="4.png"/>
<span class="caption full-caption">
<p>Content4</p>
</span>
</div>
</div>
</div>
And here's the CSS
#mktwrapper {
font: 24pt normal Arial, sans-serif;
height: auto;
margin: 0;
text-align: center;
display: table;
width: 100%;
}
#mktwrapper .row {
display: table-row;
}
#mktwrapper .box {
border: 0;
cursor: pointer;
height: 350px;
display: table-cell;
margin: 0 auto;
position: relative;
overflow: hidden;
width: 350px;
-webkit-box-shadow: 1px 1px 1px 1px #ccc;
-moz-box-shadow: 1px 1px 1px 1px #ccc;
box-shadow: 1px 1px 1px 1px #ccc;
}
#media screen and (min-width: 0px) and (max-width: 767px) {
#mktwrapper .box {
display: block;
}
}
#mktwrapper .box img {
position: absolute;
left: 0;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}
#mktwrapper .box .caption {
background-color: rgba(252,252,252,0.92);
position: absolute;
color: #111;
z-index: 100;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
left: 0;
}
#mktwrapper .box .full-caption {
width: 350px;
height: 350px;
top: -350px;
text-align: left;
padding: 15px;
}
#mktwrapper .box:hover .full-caption {
-moz-transform: translateY(100%);
-o-transform: translateY(100%);
-webkit-transform: translateY(100%);
transform: translateY(100%);
}
Thanks in advance. :)
Not sure but it might work:
CSS : Update these code lines to your CSS.
.row {
display: inline-block;
width: 100%;
text-align: center;
margin: 0px auto;
}
.box
{
display: inline-block;
}
NOTE : If you have multiple div's with class 'row' than use inline CSS or else would effect all div containing class 'row'.
I am creating a bootstrap based website. I am trying to integrate 3D flipping Menu instead of current the Menu Which is shown in the above Demo with these two Menus
For 1200px plus grid size
For less than 720px grid size
Before Integration
And
Upon Integrating it To this is what it looks like
In the first case the Menu is not getting the desired width and height without hard coding height and width.I want my menu after integration to have the height and width of menu before integration check to see the difference
How can I solve this?
HTML
<div id="Nav_Wrapper">
<ul id="Navig">
<li>
<div class="cube">
<div class="flippety">
<h1>Home</h1>
</div>
<div class="flop">
<h2>Home</h2>
</div>
</div>
</li>
<li>
<div class="cube">
<div class="flippety">
<h1>Services</h1>
</div>
<div class="flop">
<h2>Services</h2>
</div>
</div>
</li>
<li>
<div class="cube">
<div class="flippety">
<h1>About Us</h1>
</div>
<div class="flop">
<h2>About Us</h2>
</div>
</div>
</li>
<li>
<div class="cube">
<div class="flippety">
<h1>Contact us</h1>
</div>
<div class="flop">
<h2>Contact us</h2>
</div>
</div>
</li>
</ul>
</div>
CSS for 1200px
#Nav_Wrapper {
min-height: 120px;
background-color: #292929;
margin: 0;
}
#Nav_Wrapper #Navig li {
float: left;
list-style: none;
margin: 0px 0px 0px 0px;
}
#Nav_Wrapper #Navig li>a {
text-decoration: none;
}
/* Container box to set the sides relative to */
.cube {
width: 100%;
text-align: center;
/*margin: 0 auto;*/
position: relative;
height: 80px;
top: 0px;
left: 0px;
-webkit-transition: -webkit-transform .33s;
transition: transform .33s;
/* Animate the transform properties */
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
/* <-NB */;
}
/* The two faces of the cube */
.flippety {
text-decoration: none;
margin: 0px 10px 0px 0px;
padding: 0px;
font-weight: 800;
font-size: 25px;
color: #fff;
background-color: #292929;
-moz-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
-webkit-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.flop {
margin: 0px 10px 0px 0px;
font-weight: 800;
font-size: 25px;
border: 1px;
color: #777;
background-color: #323232;
border-width: 0px 0px 5px 0px;
border-color: #fff;
border-style: solid;
-moz-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
-webkit-transition: all 0.4s ease;
transition: all 0.4s ease;
}
/* Position the faces */
.flippety {
-webkit-transform: translateZ(50px);
transform: translateZ(50px);
}
.flop {
-webkit-transform: rotateX(-90deg) translateZ(-50px);
transform: rotateX(-90deg) translateZ(-50px);
}
/* Rotate the cube */
.cube:hover {
-webkit-transform: rotateX(89deg);
transform: rotateX(89deg);
/* Text bleed at 90ยบ */;
}
body {
perspective: 1000px;
}
I would like to change the opacity of the img and add a 50x50 thumbnail for zoom on hover using only CSS no jquery. This is what I have done so far.
HTML code:
<div class="span4">
<a class="zoom-icon" href="#">
<img class="blackout image-1" alt="Elite Sports" src="http://www.domain.com/images/es.jpg" width="300" height="300">
</a>
</div>
CSS code:
.span4 { margin: 35px 50px; border: 5px solid #000; }
.span4:hover { border: 5px solid #ccc; }
.span4 a:hover { background: #000; }
.blackout:hover { opacity: .0; }
I have the black background on hover working but I can't figure out how to make the thumbnail show up over top of the black background "blackout". Any helpful tips would be much appreciated.
UPDATE w/Fiddle:
http://jsfiddle.net/8BMYH/
Something like this
http://jsfiddle.net/8BMYH/14/
HTML
<div class="span4"> <a class="portfolio-link-icon" href="http://www.elitesports.com"><
<img class="alignnone blackout size-full wp-image-2592" alt="Elite Sports" src="http://www.surgicalgeeks.com/wp-content/uploads/2013/04/es.jpg" width="300" height="300" />
<img class="zoom-link" src="http://www.surgicalgeeks.com/wp-content/uploads/2013/04/portfolio-link-icon.png" />
</a>
</div>
CSS
span4 {
background: #000;
margin: 35px 50px;
width: 300px !important;
height: 300px;
border: 5px solid black;
float: left;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
box-shadow: 1px 1px 5px #000;
}
.span4:hover {
overflow: hidden;
border: 5px solid #8b8c8d;
border-radius: 25%;
-webkit-transform: rotate(290deg);
-moz-transform: rotate(290deg);
-o-transform: rotate(290deg);
-ms-transform: rotate(290deg);
transform: rotate(290deg);
}
.blackout:hover {
opacity: .0;
}
.zoom-link {
top: 130px;
left: 130px;
position: absolute;
visibility: hidden;
}
.span4:hover .zoom-link {
position: absolute;
visibility: visible;
}
.span4:hover .blackout {
opacity: 0;
}
You can add the thumbnail when you hover over the link using the :after pseudo-element. I created a Pen that demonstrates this: http://codepen.io/Ghodmode/pen/xFmqf
This isn't an ideal solution, but it is entirely CSS. It would be better if I could get the value of the src attribute from the image and use that as the background url using the attr() (http://www.w3.org/TR/css3-values/#attr) CSS function, but I couldn't get that to work.
.span4 a.zoom-icon {
position: relative;
}
.span4 a.zoom-icon:hover:after {
content: "";
display: block;
position: absolute;
width: 50px;
height: 50px;
bottom: 10px;
right: 10px;
background-color: black;
background-image: url("http://bit.ly/XioiVs");
background-position: center;
background-repeat: no-repeat;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-size: contain;
}