So I got this code for a section in my page that uses a "!important" value on the css to make it work properly but I feel like it might be affecting the responsive side of it. I currently got the section to look properly on small devices but once I click(or hover) anywhere on the section, the section once again goes weird and I can't help but to think that the .projects-others:hover {width: 60% !important;} is behind it since it won't let me turn the transition off. How can I take it off for small devices but keep it on regular size? I've even tried putting the !important value on the transition queries but still no luck.
/*project section starts*/
.projects {
overflow: hidden;
height: 27em;
margin-top: 50px;
border: ;
}
.projects a {
cursor: default;
}
.box {
box-sizing: border-box;
box-shadow: 1.1px 1.2px #595959;
}
.projects h1 {
font-size: 4.40em;
text-align: center;
text-shadow: 0 3px 3px rgba(0, 0, 0, 0.9);
font-family: 'Dancing Script', cursive;
line-height: 80px;
padding-top: 2px;
}
.projects-others,
.projects-coding {
width: 50%;
-moz-transition: width .3s;
-webkit-transition: width .3s;
-o-transition: width .3s;
transition: width .3s;
height: 27em;
padding: 1em;
box-sizing: border-box;
}
.projects-others {
float: right;
background: #00004d;
background-size: cover;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
}
.projects-coding {
background: white;
border-right: ;
}
.projects:hover .projects-others {
width: 40%;
}
.projects-coding:hover {
width: 60%;
}
/*the code that I think is causing the problem*/
.projects-others:hover {
width: 60% !important;
}
.projects-others:hover~.projects-coding {
width: 40%;
}
/*courosel section starts*/
.slideshow-container {
max-width: 1000px;
height: 7.5em;
position: relative;
margin: 7.5px auto;
}
.mySlides,
.mySlides2 {
display: none;
}
.project-text {
display: flex;
width: 100%;
justify-content: center;
align-items: center;
font-family: 'Inknut Antiqua', serif;
}
.slideshow-img {
width: 17.4rem;
height: 10.5rem;
border-radius: 5px;
box-shadow: 2.5px 2.5px 2px rgba(0, 0, 0, 0.7);
-webkit-transition: display 1s;
transition: all 1s;
}
.slide-hover-p {
display: none;
}
.slideshow-img:hover+.slide-hover-p {
display: block;
}
.fade-car {
-moz-animation-name: fade-car;
-webkit-animation-name: fade-car;
-moz-animation-duration: 2.5s;
-webkit-animation-duration: 2.5s;
}
.previous,
.nexxt {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 16px;
margin-top: ;
font-weight: bold;
font-size: 28px;
transition: 0.85s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
.nexxt {
right: 0;
border-radius: 3px 0 0 3px;
}
.previous:hover,
.nexxt:hover {
cursor: pointer;
}
#p-others:hover,
#n-others:hover {
background-color: white;
color: #00004d;
}
#p-coding:hover,
#n-coding:hover {
background-color: #00004d;
color: white;
}
/*courosel media queries*/
#-webkit-keyframes fade-car {
from {
opacity: 0.4
}
to {
opacity: 1
}
}
#keyframes fade-car {
from {
opacity: 0.4
}
to {
opacity: 1
}
}
#media only screen and (max-width: 300px) {
.previous,
.nexxt,
.text {
font-size: 11px
}
}
#coding-github-btn {
font-size: 1.35em;
font-weight: 400;
background: #00004d;
border: 1px solid #00004d;
transition: all 0.9s;
cursor: pointer;
}
#coding-github-btn:hover,
#coding-github-btn:focus {
background: white;
border: 1px solid #00004d;
color: #00004d;
}
#others-etsy-btn {
font-size: 1.175em;
font-weight: 500;
background: #ffdb4d;
border: 1px solid #ffdb4d;
transition: all 0.6s;
color: #00004d;
cursor: pointer;
}
#others-etsy-btn:hover,
#others-etsy-btn:focus {
opacity: 0.7;
}
/*media queries for section*/
#media only screen and (max-width: 575px) {
.projects {
height: auto;
-moz-transition: none;
-webkit-transition: none;
-o-transition: none;
transition: none;
}
.projects a {
transition: none;
}
.projects-others, .projects-coding {
-moz-transition: none;
-webkit-transition: none;
-o-transition: none;
transition: none;
height: auto;
width: 100%;
max-width: 100%;
flex: 100%;
}
}
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/css?family=Josefin+Sans|Inknut+Antiqua|Dancing+Script|Courgette&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"><!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="profile-css/profile-stylesheet.css" type="text/css" />
<link rel="stylesheet" href="profile-css/mq-stylesheet.css" type="text/css" />
</head>
<body>
<!--project section headings-->
<div class="projects">
<a>
<div class="box projects-others" style="color: #ffdb4d;">
<h1 style="color: #ffdb4d;">Projects :<br> Others</h1>
<!--slider starts-->
<div class="slideshow-container">
<div class="mySlides fade-car">
<div class="project-text">
<img src="images/colorado_view2.jpg" class="slideshow-img img-fluid" alt="global6" />
<p class="slide-hover-p"><i>(My Profile Webpage)</i></p>
</div>
</div>
<div class="mySlides fade-car">
<div class="project-text">
<img src="images/global (35).jpg" class="slideshow-img img-fluid" alt="global6" />
<p class="slide-hover-p"><i>(My Profile Webpage)</i></p>
</div>
</div>
<div class="mySlides fade-car">
<div class="project-text">
<img src="images/global (35).jpg" class="slideshow-img img-fluid" alt="global6" />
<p class="slide-hover-p"><i>(My Profile Webpage)</i></p>
</div>
</div>
<a id="p-others" class="previous" onclick="plusSlides(-1)">❮</a>
<a id="n-others" class="nexxt" onclick="plusSlides(1)">❯</a>
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
</div>
<!--slideshow ends-->
<br><br>
<div class="w-100 text-center">
<a id="others-etsy-btn" href="#" class="btn" role="button">My Etsy Store <span class="fa fa-etsy"></span></a>
</div>
</div>
</a>
<a>
<div class="box projects-coding" style="color:#00004d;">
<h1 style="color:#00004d;">Projects :<br> Coding</h1>
<!--second slider starts-->
<div class="slideshow-container">
<div class="mySlides2 fade-car">
<div class="project-text">
<img src="images/global (35).jpg" class="slideshow-img img-fluid" alt="global6" />
<p class="slide-hover-p"><i>(My Profile Webpage)</i></p>
</div>
</div>
<div class="mySlides2 fade-car">
<div class="project-text">
<img src="images/global (35).jpg" class="slideshow-img img-fluid" alt="global6" />
<p class="slide-hover-p"><i>(My Profile Webpage)</i></p>
</div>
</div>
<div class="mySlides2 fade-car">
<div class="project-text">
<img src="images/global (35).jpg" class="slideshow-img img-fluid" alt="global6" />
<p class="slide-hover-p"><i>(My Profile Webpage)</i></p>
</div>
</div>
<a id="p-coding" class="previous" onclick="plusSlides2(-1)">❮</a>
<a id="n-coding" class="nexxt" onclick="plusSlides2(1)">❯</a>
<span class="dot2" onclick="currentSlide2(1)"></span>
<span class="dot2" onclick="currentSlide2(2)"></span>
<span class="dot2" onclick="currentSlide2(3)"></span>
</div>
<!--slider ends-->
<br><br>
<div class="w-100 text-center">
<a id="coding-github-btn" href="#" class="btn" role="button">My Repositories <span class="fa fa-github"></span></a>
</div>
</div>
</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script><!-- Popper JS -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script><!-- Latest compiled bootstrap JavaScript -->
</body>
</html>
Placing a media query at the bottom of your css file with the same class and using important as well would definitely fix this.
I have a problem with this slideshow:
https://codepen.io/bcarvalho/pen/gWPvJB
The HTML is:
<main class="main-content">
<section class="slideshow">
<div class="slideshow-inner">
<div class="slides">
<div class="slide is-active ">
<div class="slide-content">
<div class="caption">
<div class="title">Slide title 1</div>
<div class="text">
<p>Slide description 1</p>
</div>
<a href="#" class="btn">
<span class="btn-inner">Learn More</span>
</a>
</div>
</div>
<div class="image-container">
<img src="https://www.alixbdanthenay.fr/wp-content/uploads/2015/07/Indispensable-1.jpg" alt="" class="image" />
</div>
</div>
<div class="slide">
<div class="slide-content">
<div class="caption">
<div class="title">Slide title 2</div>
<div class="text">
<p>Slide description 2</p>
</div>
<a href="#" class="btn">
<span class="btn-inner">Learn More</span>
</a>
</div>
</div>
<div class="image-container">
<img src="https://www.alixbdanthenay.fr/wp-content/uploads/2015/07/Indispensable-4-1.jpg" alt="" class="image" />
</div>
</div>
<div class="slide">
<div class="slide-content">
<div class="caption">
<div class="title">Slide title 3</div>
<div class="text">
<p>Slide description 3</p>
</div>
<a href="#" class="btn">
<span class="btn-inner">Learn More</span>
</a>
</div>
</div>
<div class="image-container">
<img src="https://www.alixbdanthenay.fr/wp-content/uploads/2016/11/11.jpg" alt="" class="image" />
</div>
</div>
<div class="slide">
<div class="slide-content">
<div class="caption">
<div class="title">Slide title 4</div>
<div class="text">
<p>Slide description 4</p>
</div>
<a href="#" class="btn">
<span class="btn-inner">Learn More</span>
</a>
</div>
</div>
<div class="image-container">
<img src="https://www.alixbdanthenay.fr/wp-content/uploads/2016/11/20mars17-sans-typo.jpg" alt="" class="image" />
</div>
</div>
</div>
<div class="pagination">
<div class="item is-active">
<span class="icon">1</span>
</div>
<div class="item">
<span class="icon">2</span>
</div>
<div class="item">
<span class="icon">3</span>
</div>
<div class="item">
<span class="icon">4</span>
</div>
</div>
<div class="arrows">
<div class="arrow prev">
<span class="svg svg-arrow-left">
<svg version="1.1" id="svg4-Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="14px" height="26px" viewBox="0 0 14 26" enable-background="new 0 0 14 26" xml:space="preserve"> <path d="M13,26c-0.256,0-0.512-0.098-0.707-0.293l-12-12c-0.391-0.391-0.391-1.023,0-1.414l12-12c0.391-0.391,1.023-0.391,1.414,0s0.391,1.023,0,1.414L2.414,13l11.293,11.293c0.391,0.391,0.391,1.023,0,1.414C13.512,25.902,13.256,26,13,26z"/> </svg>
<span class="alt sr-only"></span>
</span>
</div>
<div class="arrow next">
<span class="svg svg-arrow-right">
<svg version="1.1" id="svg5-Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="14px" height="26px" viewBox="0 0 14 26" enable-background="new 0 0 14 26" xml:space="preserve"> <path d="M1,0c0.256,0,0.512,0.098,0.707,0.293l12,12c0.391,0.391,0.391,1.023,0,1.414l-12,12c-0.391,0.391-1.023,0.391-1.414,0s-0.391-1.023,0-1.414L11.586,13L0.293,1.707c-0.391-0.391-0.391-1.023,0-1.414C0.488,0.098,0.744,0,1,0z"/> </svg>
<span class="alt sr-only"></span>
</span>
</div>
</div>
</div>
</section>
</main>
The SCSS code is :
body {
font: 14px/2 "Open sans",sans-serif;
letter-spacing: 0.05em;
}
.btn {
display: inline-block;
padding: 13px 20px;
color: #fff;
text-decoration: none;
position: relative;
background: transparent;
border: 1px solid #e1e1e1;
font: 12px/1.2 "Oswald", sans-serif;
letter-spacing: 0.4em;
text-align: center;
text-indent: 2px;
text-transform: uppercase;
transition: color 0.1s linear 0.05s;
&::before {
content: "";
display: block;
position: absolute;
top: 50%;
left: 0;
width: 100%;
height: 1px;
background: #e1e1e1;
z-index: 1;
opacity: 0;
transition: height 0.2s ease, top 0.2s ease, opacity 0s linear 0.2s;
}
&::after {
transition:border 0.1s linear 0.05s;
}
.btn-inner {
position: relative;
z-index: 2;
}
&:hover {
color: #373737;
transition: color 0.1s linear 0s;
&::before {
top: 0;
height: 100%;
opacity: 1;
transition: height 0.2s ease, top 0.2s ease, opacity 0s linear 0s;
}
&::after {
border-color: #373737;
transition:border 0.1s linear 0s;
}
}
}
.slideshow {
overflow: hidden;
position: relative;
width: 100%;
height: 100vh;
z-index: 1;
.slideshow-inner {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.slides {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.slide {
display: none;
overflow: hidden;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
opacity: 0;
transition: opacity 0.3s ease;
&.is-active {
display: block;
}
&.is-loaded{
opacity: 1;
}
.caption {
padding: 0 100px;
}
.image-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-position: center;
z-index: 1;
background-size: cover;
image-rendering: optimizeQuality;
&::before {
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
}
}
.image {
width: 100%;
width: 100%;
object-fit: cover;
height: 100%;
}
&-content {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 2;
color: #fff;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
.title {
margin: 0 auto 15px;
max-width: 1000px;
font: 300 50px/1.2 "Oswald", sans-serif;
letter-spacing: 0.35em;
text-transform: uppercase;
}
.text {
margin: 0 auto;
max-width: 1000px;
font-size: 18px;
line-height: 1.4;
}
.btn {
margin: 15px 0 0;
border-color: #fff;
&::before {
background:#fff
}
}
}
.pagination {
position: absolute;
bottom: 35px;
left: 0;
width: 100%;
height: 12px;
cursor: default;
z-index: 2;
text-align: center;
.item {
display: inline-block;
padding: 15px 5px;
position: relative;
width: 46px;
height: 32px;
cursor: pointer;
text-indent: -999em;
z-index: 1;
+ .page {
margin-left: -2px;
}
&::before {
content: "";
display: block;
position: absolute;
top: 15px;
left: 5px;
width: 36px;
height: 2px;
background: rgba(255, 255, 255, 0.5);
transition: background 0.2s ease;
}
&::after {
width: 0;
background: #fff;
z-index: 2;
transition: width 0.2s ease;
}
&:hover::before,
&.is-active::before {
background-color: #fff;
}
}
}
.arrows {
.arrow {
margin: -33px 0 0;padding: 20px;position: absolute;top: 50%;cursor: pointer;z-index: 3;
}
.prev {
left: 30px;
&:hover .svg {
left: -10px;
}
}
.next {
right: 30px;
&:hover .svg {
left: 10px;
}
}
.svg {
position: relative;
left: 0;
width: 14px;
height: 26px;
fill: #fff;
transition: left 0.2s ease;
}
}
}
The JavaScript code is:
var slideshowDuration = 500;
var slideshow=$('.main-content .slideshow');
function slideshowSwitch(slideshow,index,auto){
if(slideshow.data('wait')) return;
var slides = slideshow.find('.slide');
var pages = slideshow.find('.pagination');
var activeSlide = slides.filter('.is-active');
var activeSlideImage = activeSlide.find('.image-container');
var newSlide = slides.eq(index);
var newSlideImage = newSlide.find('.image-container');
var newSlideContent = newSlide.find('.slide-content');
var newSlideElements=newSlide.find('.caption > *');
if(newSlide.is(activeSlide))return;
newSlide.addClass('is-new');
var timeout=slideshow.data('timeout');
clearTimeout(timeout);
slideshow.data('wait',true);
var transition=slideshow.attr('data-transition');
if(transition=='fade'){
newSlide.css({
display:'block',
zIndex:2
});
newSlideImage.css({
opacity:0
});
TweenMax.to(newSlideImage,1,{
alpha:1,
onComplete:function(){
newSlide.addClass('is-active').removeClass('is-new');
activeSlide.removeClass('is-active');
newSlide.css({display:'',zIndex:''});
newSlideImage.css({opacity:''});
slideshow.find('.pagination').trigger('check');
slideshow.data('wait',false);
if(auto){
timeout=setTimeout(function(){
slideshowNext(slideshow,false,true);
},slideshowDuration);
slideshow.data('timeout',timeout);}}});
} else {
if(newSlide.index()>activeSlide.index()){
var newSlideRight=0;
var newSlideLeft='auto';
var newSlideImageRight=-slideshow.width()/8;
var newSlideImageLeft='auto';
var newSlideImageToRight=0;
var newSlideImageToLeft='auto';
var newSlideContentLeft='auto';
var newSlideContentRight=0;
var activeSlideImageLeft=-slideshow.width()/4;
} else {
var newSlideRight='';
var newSlideLeft=0;
var newSlideImageRight='auto';
var newSlideImageLeft=-slideshow.width()/8;
var newSlideImageToRight='';
var newSlideImageToLeft=0;
var newSlideContentLeft=0;
var newSlideContentRight='auto';
var activeSlideImageLeft=slideshow.width()/4;
}
newSlide.css({
display:'block',
width:0,
right:newSlideRight,
left:newSlideLeft
,zIndex:2
});
newSlideImage.css({
width:slideshow.width(),
right:newSlideImageRight,
left:newSlideImageLeft
});
newSlideContent.css({
width:slideshow.width(),
left:newSlideContentLeft,
right:newSlideContentRight
});
activeSlideImage.css({
left:0
});
TweenMax.set(newSlideElements,{y:20,force3D:true});
TweenMax.to(activeSlideImage,1,{
left:activeSlideImageLeft,
ease:Power3.easeInOut
});
TweenMax.to(newSlide,1,{
width:slideshow.width(),
ease:Power3.easeInOut
});
TweenMax.to(newSlideImage,1,{
right:newSlideImageToRight,
left:newSlideImageToLeft,
ease:Power3.easeInOut
});
TweenMax.staggerFromTo(newSlideElements,0.8,{alpha:0,y:60},{alpha:1,y:0,ease:Power3.easeOut,force3D:true,delay:0.6},0.1,function(){
newSlide.addClass('is-active').removeClass('is-new');
activeSlide.removeClass('is-active');
newSlide.css({
display:'',
width:'',
left:'',
zIndex:''
});
newSlideImage.css({
width:'',
right:'',
left:''
});
newSlideContent.css({
width:'',
left:''
});
newSlideElements.css({
opacity:'',
transform:''
});
activeSlideImage.css({
left:''
});
slideshow.find('.pagination').trigger('check');
slideshow.data('wait',false);
if(auto){
timeout=setTimeout(function(){
slideshowNext(slideshow,false,true);
},slideshowDuration);
slideshow.data('timeout',timeout);
}
});
}
}
function slideshowNext(slideshow,previous,auto){
var slides=slideshow.find('.slide');
var activeSlide=slides.filter('.is-active');
var newSlide=null;
if(previous){
newSlide=activeSlide.prev('.slide');
if(newSlide.length === 0) {
newSlide=slides.last();
}
} else {
newSlide=activeSlide.next('.slide');
if(newSlide.length==0)
newSlide=slides.filter('.slide').first();
}
slideshowSwitch(slideshow,newSlide.index(),auto);
}
function homeSlideshowParallax(){
var scrollTop=$(window).scrollTop();
if(scrollTop>windowHeight) return;
var inner=slideshow.find('.slideshow-inner');
var newHeight=windowHeight-(scrollTop/2);
var newTop=scrollTop*0.8;
inner.css({
transform:'translateY('+newTop+'px)',height:newHeight
});
}
$(document).ready(function() {
$('.slide').addClass('is-loaded');
$('.slideshow .arrows .arrow').on('click',function(){
slideshowNext($(this).closest('.slideshow'),$(this).hasClass('prev'));
});
$('.slideshow .pagination .item').on('click',function(){
slideshowSwitch($(this).closest('.slideshow'),$(this).index());
});
$('.slideshow .pagination').on('check',function(){
var slideshow=$(this).closest('.slideshow');
var pages=$(this).find('.item');
var index=slideshow.find('.slides .is-active').index();
pages.removeClass('is-active');
pages.eq(index).addClass('is-active');
});
/* Lazyloading
$('.slideshow').each(function(){
var slideshow=$(this);
var images=slideshow.find('.image').not('.is-loaded');
images.on('loaded',function(){
var image=$(this);
var slide=image.closest('.slide');
slide.addClass('is-loaded');
});
*/
var timeout=setTimeout(function(){
slideshowNext(slideshow,false,true);
},slideshowDuration);
slideshow.data('timeout',timeout);
});
if($('.main-content .slideshow').length > 1) {
$(window).on('scroll',homeSlideshowParallax);
}
I want to copy the files from the web pages to my website.
I changed the SCSS to CSS but it doesn't work. What's the problem?
The code I used to change the SCSS is:
sass filename.scss newfilename.css
But it looks bad after I change it.
In the CodePen link you posted, try and click the arrow in the top right corner of the CSS panel, and select "View compiled CSS". This will also give you the CSS you need.
There already a function to change SCSS on Codepen but if there any chance Codepen Does not work, try other website like JSFiddle,CSS Deck,JS Bin,Dabblet,Plunker,Liveweave.
Credit to https://www.sitepoint.com/7-code-playgrounds/
i find the problem , in :
https://codepen.io
can't the files all be in three windows so i need to download the slideshow from
the button in right down in right "Export.zip" and download the file and use it !
thanks for all you for staying with me ♥
So I am trying to make a loop of images that has description overlaying each of it. The overlay would be visible when the picture is hovered. Here is an example of the code.
.container {
height: 100px;
width:100px;
display: inline-block;
}
.picture {
height: 100%;
width:100%
}
.contAlign {
text-align: center;
}
.desc {
position:flex;
bottom: 0;
left: 0;
right: 0;
background-color: black;
width: 100%;
height: 0%;
opacity: 0.5;
transition: .5s ease;
}
.container:hover .desc {
height: 40%;
}
<div class="contAlign">
<div class="container">
<img class="picture" src="https://kbob.github.io/images/sample-3.jpg">
<div class="desc"></div>
</div>
<div class="container">
<img class="picture" src="https://imagej.nih.gov/ij/images/baboon.jpg">
<div class="desc"></div>
</div>
<div class="container">
<img class="picture" src="https://www.visioncritical.com/wp-content/uploads/2014/12/BLG_Andrew-G.-River-Sample_09.13.12.png">
<div class="desc"></div>
</div>
</div>
In this case, the description box goes downwards since I wasnt using position: absolute;. However if I do so, the box wont inherit the pictures size and takes the size of the page. How do I solve this?
FIDDLE
Set the position of container to relative so the description would be absolute in relation to it:
.container {
height: 100px;
width:100px;
display: inline-block;
position:relative;
}
.picture {
height: 100%;
width:100%
}
.contAlign {
text-align: center;
}
.desc {
position:absolute;
bottom: 0;
left: 0;
right: 0;
background-color: black;
width: 100%;
height: 0%;
opacity: 0.5;
transition: .5s ease;
}
.container:hover .desc {
height: 40%;
}
<div class="contAlign">
<div class="container">
<img class="picture" src="https://kbob.github.io/images/sample-3.jpg">
<div class="desc"></div>
</div>
<div class="container">
<img class="picture" src="https://imagej.nih.gov/ij/images/baboon.jpg">
<div class="desc"></div>
</div>
<div class="container">
<img class="picture" src="https://www.visioncritical.com/wp-content/uploads/2014/12/BLG_Andrew-G.-River-Sample_09.13.12.png">
<div class="desc"></div>
</div>
</div>
I hope this helps you out. once you make an element absolute, just make sure to make its parent relative. so that it doesn't float anywhere. Now you can set positions accordingly where you want to make it appear on hover.
.container {
height: 100px;
width:100px;
display: inline-block;
position: relative;
}
.picture {
height: 100%;
width:100%
}
.contAlign {
text-align: center;
}
.desc {
position:absolute;
bottom: 0;
left: 0;
right: 0;
background-color: black;
width: 100%;
height: 0%;
opacity: 0.5;
transition: .5s ease;
}
.container:hover .desc {
height: 40%;
}
<div class="contAlign">
<div class="container">
<img class="picture" src="https://kbob.github.io/images/sample-3.jpg">
<div class="desc"></div>
</div>
<div class="container">
<img class="picture" src="https://imagej.nih.gov/ij/images/baboon.jpg">
<div class="desc"></div>
</div>
<div class="container">
<img class="picture" src="https://www.visioncritical.com/wp-content/uploads/2014/12/BLG_Andrew-G.-River-Sample_09.13.12.png">
<div class="desc"></div>
</div>
</div>
I have an image gallery with some hover affects that I want to refine. When the user hovers on an image, the other pictures in the gallery get dimmed out. But I also want some text to slide in from the left on hover as well. Something like this website has http://gugroppo.com/projects.
I have the text appear on hover but I can't get it to transition in from the left smoothly; or have my overlay effect appear smoothly as well. Everything just appears. Here's my codepen.
window.sr = ScrollReveal({reset: true});
sr.reveal('img', {mobile:true});
body {
margin: 0;
padding: 0;
}
h2 {
padding-bottom: 7.5%;
color: #7bbe9a;
text-align: center;
font-size: 1.875em;
font-family: 'Lato', sans-serif;
}
.gallery{
width: 100%;
display: inline-block;
flex-wrap: wrap;
justify-content: center;
padding-top: 7.5%;
padding-bottom: 15%;
background-color: #333;
}
.img-container {
-webkit-transition: opacity 0.3s;
-moz-transition: opacity 0.3s;
-ms-transition: opacity 0.3s;
-o-transition: opacity 0.3s;
transition: opacity 0.3s;
width: 33.33%;
float: left;
display: block;
position: relative;
}
.img-container img{
display: block;
width: 100%;
height: auto;
}
#slide {
position: absolute;
left: -100px;
transition: 1s;
width: 100%;
height: 100%;
}
.overlay {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
right: 0;
bottom: 0;
opacity: 0;
/* background: rgba(123, 190, 154, 0.72); */
background: rgba(51,51,51, 0.2);
}
.text {
color: white;
position: absolute;
top: 50%;
left: 50%;
font-size: 24px;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
font-family: 'Lato', sans-serif;
}
#parent:hover > .img-container:not(:hover) {
opacity: 0.3;
}
.img-container:hover .overlay {
opacity: 1;
}
#media(max-width:768px){
.img-container {
width: 100% !important;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://unpkg.com/scrollreveal/dist/scrollreveal.min.js"></script>
<body>
<a class="anchor" name="portfolio">
<div class="gallery">
<h2>Portfolio</h2>
</a>
<div id="parent">
<div class="img-container">
<a href="">
<img src="https://img1.cgtrader.com/items/4716/33d9798412/large/wicker-laundry-basket-3d-model-obj-3ds-c4d.jpg" alt=""></a>
<div class="overlay">
<div class="text">Basket</div>
</div>
</div>
<div class="img-container">
<a href="">
<img src="https://cdn.shopify.com/s/files/1/0225/1115/products/buildings-rts-orc-smithy-low-poly-3d-model-2_400x.jpeg?v=1456744435" alt=""></a>
<div class="overlay">
<div class="text">Train</div>
</div>
</div>
<div class="img-container">
<a href="">
<img src="http://www.pycomall.com/images/P1/Bed_Room_Interior_3D_Model_in_Max_format_7.jpg" alt=""></a>
<div class="overlay">
<div class="text">Bed</div>
</div>
</div>
<div class="img-container">
<a href="">
<img src="http://mycreativedaddy.com/wp-content/uploads/chair-capitone-3d-model.jpg" alt=""></a>
<div class="overlay">
<div class="text">Chair</div>
</div>
</div>
<div class="img-container">
<a href="">
<img src="http://www.pycomall.com/images/P1/Restaurant_Interior_3D_Model_in_Max_format_4.jpg" alt=""></a>
<div class="overlay">
<div class="text">Room</div>
</div>
</div>
<div class="img-container">
<a href="">
<img src="https://3dexport.com/items/2008/07/29/11820/9454/wedding_ring._3d_model_c4d_max_obj_fbx_ma_lwo_3ds_3dm_stl_66996.jpg" alt=""></a>
<div class="overlay">
<div class="text">Ring</div>
</div>
</div>
<div class="img-container">
<a href="">
<img src="http://www.madsonline.net/wp-content/uploads/2017/07/living-room-interior-3d-model-in-max-format-3-3d-models-in-3d-living-room-model.jpg" alt=""></a>
<div class="overlay">
<div class="text">Couch</div>
</div>
</div>
<div class="img-container">
<a href="">
<img src="https://d1a9v60rjx2a4v.cloudfront.net/2013/10/03/00_54_27_730_00_1.jpg" alt=""></a>
<div class="overlay">
<div class="text">Glass</div>
</div>
</div>
<div class="img-container">
<a href="">
<img src="https://img1.cgtrader.com/items/5185/bb5b9f2fde/large/bailarina-3d-model-obj-3ds-fbx-ma-mb.jpg" alt=""></a>
</div>
</div>
</body>
What you want to do is add overflow: hidden to your container
.img-container{overflow: hidden;}
Then initially start the text off the element. I did this by setting
.text{left: -50%;}
Finally you need to call the text back into the element on hover by using container:hover and setting the text back to 50%;
.img-container:hover .text{left: 50%;}
Lastly you will just need to add in some transition properties and attributes of your likely. Hope this helps.
The follow CSS should accomplish what you are looking for
body {
margin: 0;
padding: 0;
}
h2 {
padding-bottom: 7.5%;
color: #7bbe9a;
text-align: center;
font-size: 1.875em;
font-family: 'Lato', sans-serif;
}
.gallery{
width: 100%;
display: inline-block;
flex-wrap: wrap;
justify-content: center;
padding-top: 7.5%;
padding-bottom: 15%;
background-color: #333;
}
.img-container {
-webkit-transition: opacity 0.3s;
-moz-transition: opacity 0.3s;
-ms-transition: opacity 0.3s;
-o-transition: opacity 0.3s;
transition: opacity 0.3s;
width: 33.33%;
float: left;
display: block;
position: relative;
overflow: hidden;
}
.img-container img{
display: block;
width: 100%;
height: auto;
}
#slide {
position: absolute;
left: -100px;
transition: 1s;
width: 100%;
height: 100%;
}
.overlay {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
right: 0;
bottom: 0;
opacity: 0;
/* background: rgba(123, 190, 154, 0.72); */
background: rgba(51,51,51, 0.2);
}
.text {
color: white;
position: absolute;
top: 50%;
left: -50%;
font-size: 24px;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
font-family: 'Lato', sans-serif;
}
.img-container:hover .text {
left: 50%;
}
#parent:hover > .img-container:not(:hover) {
opacity: 0.3;
}
.img-container:hover .overlay {
opacity: 1;
}
#media(max-width:768px){
.img-container {
width: 100% !important;
}
}
So I would like to cover the whole thumbnail when hovering over, so that the overlay content fills the whole image, 100% by 100%. So the overlay should cover only image(whole size of it), not more than that.
Here's the pen to demonstrate the current state: http://codepen.io/anon/pen/JbJgoe
.about__images {
max-width: 800px;
margin: 0 auto;
}
.about__inner {
margin-top: 60px;
}
.about__inner img {
max-width: 100%;
margin-right: 20px;
}
.about .about__inner {
position: relative;
overflow: hidden;
}
.about .about__inner .about__inner--overlay {
background: rgba(0, 0, 0, .75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
transition: opacity .25s ease;
}
.about .about__inner:hover .about__inner--overlay {
opacity: 1;
}
<div class="container about">
<div class="about__images">
<div class="row">
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="" class="hideonhover">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
</div>
</div>
</div>
You are close to it. Just a small modification in structure and a few lines in css:
HTML:
<div class="col-md-4">
<div class="about__inner">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="" class="hideonhover">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
CSS:
.about .about__inner .about__inner--overlay {
background: rgba(0, 0, 0, .75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
transition: opacity .25s ease;
position: absolute;
top:0;
width:100%;
height:100%;
}
.about__inner{
position:relative;
}
.about__inner--overlay{
color:#fff;
}
Codepen: http://codepen.io/swapnaranjitanayak/pen/oYwKLO
You need to use absolute positionning and size the box. You may use coordonates to size the box so it fits any size since you already set the parent in relative positionning..
.about .about__inner .about__inner--overlay {
background: rgba(0, 0, 0, .75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
transition: opacity .25s ease;
top:0;
left:15px;
right:15px;
bottom:0;
color:white;
position:absolute
}
.about__images {
max-width: 800px;
margin: 0 auto;
}
.about__inner {
margin-top: 60px;
}
.about__inner img {
max-width: 100%;
padding-right: 20px;
}
.about .about__inner {
position: relative;
overflow: hidden;
}
.about .about__inner .about__inner--overlay {
background: rgba(0, 0, 0, .75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
transition: opacity .25s ease;
top:0;
left:15px;
right:35px;
bottom:0;
color:white;
position:absolute
}
.about .about__inner:hover .about__inner--overlay {
opacity: 1;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="container about">
<div class="about__images">
<div class="row">
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="" class="hideonhover">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
</div>
</div>
</div>
Try this:
.about__inner {
padding: 0px; //for full frame image
}
.about__inner img {
max-width: 100%;
max-height: 100%;
object-fit: cover; //force image display as cover, no scale
}
.about .about__inner .about__inner--overlay {
position: absolute; //You need it to arrange the div.
top: 0px;
left:0px;
width: 100%;
height: 100%;
}
Try this:
.about__images {
max-width: 800px;
margin: 0 auto;
}
.about__inner {
margin-top: 60px;
}
.about__inner img {
max-width: 100%;
margin-right: 20px;
}
.about .about__inner {
position: relative;
overflow: hidden;
}
.about .about__inner .about__inner--overlay {
background: rgba(0, 0, 0, .75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
transition: opacity .25s ease;
}
.about .about__inner:hover .about__inner--overlay {
opacity: 1;
position: relative;
height: 185px;
top: -185px;
}