HTML FILE:
<div class="one">
<div class="two">
<h2>ITEM NAME</h2>
</div>
</div>
CSS:
html, body {
height: 100%;
width: 100%;
}
.one{
display:block;
position: relative;
margin-left:auto;
margin-right:auto;
width:50%;
height:325px;
background-image: url('http://hd.wallpaperswide.com/thumbs/lion_5-t2.jpg');
background-size:cover;
}
.two{
position:absolute;
display:inline-block;
width:100%;
height:100%;
background-color: gray;
transition: all 0.3s ease-out;
}
.two h2{padding-top: 20%;}
I want to make a hover transition effect, just like this website:
Here
You can see in portfolio when you hover the link another light-blue div expands. I guess it's using transform: scale() I tried to do something like that, but the second div is overpassing the size of the parent div. How may I fix that? What am I doing wrong?
Also, I have my codepen sample.
The image of the lion you are using has a transparent background which appears along the edges, giving the impression that div one is actually smaller than it is. Set the background on the div one to a background colour instead of an image, and you will see what i mean.
i holp to help:
.one{
display:block;
position: relative;
margin-left:auto;
margin-right:auto;
width:510px;
height:330px;
background-image: url('http://hd.wallpaperswide.com/thumbs/lion_5-t2.jpg');
background-size:cover;
border:1px solid blue;
}
.two{
position:absolute;
display:block;
width:10%;
height:10%;
background-color: gray;
transition: all 0.3s ease-out;
margin-left:50%;
margin-top:30%;
opacity:0;
border-radius:100px;
}
.two h2{margin-top: 20%; margin-left:20%;}
.one:hover .two{
display:inline-block;
opacity: 1;
width:100%;
height:100%;
-webkit-transform: scale(1);
margin:0px !important;
border-radius:2px !important;
}
Related
How could to show left side of image at begin, and show right side on mouse hover.
body{
background:gray;
}
img{
width: 100px;
}
img:hover {
}
<img src="https://i.stack.imgur.com/AQdqr.png" >
I'm not sure if this is what you need, but you yourself can remake this code for your task.
body {
background: gray;
}
img {
width: 50px;
height: 50px;
object-fit: cover;
object-position: 0;
}
img:hover {
object-position: 100%;
}
<img src="https://i.stack.imgur.com/AQdqr.png">
I will sugest to add a container with two elements inside : your image and a div that will hide half of your image, and on hover we will remove div to show your img
.container{
position:relative;
width:150px;
height:150px;
border:2px solid black;
}
.container:hover .bg{
width:0%;
}
.bg{
transition:all .2s;
position:absolute;
right:0;
width:50%;
height:100%;
background:white;
}
img{
position:absolute;
height:100%;
object-fit: contain;
}
<div class="container">
<img src="https://i.stack.imgur.com/AQdqr.png"/>
<div class="bg"></div>
</div>
Youre not clear what you want. I think you want different color while hovering on the picture.
For this crop this picture to a single object. Then you can use css grayscale filter on hover.
body {
background: gray;
}
img {
width: 100px;
}
img:hover {
filter: grayscale(100%);
transition: 1s;
}
<img src="https://i.stack.imgur.com/AQdqr.png">
I'm having an image within a parent div transition into a blurred state when hovered over. However if the image is 100% width/height of the parent, when blurred you get a bezel of the parent's background color. So I tried making the image say 140% width/height and/or negative left/right/top/bottom without success. This method does get rid of the bezel but not until the very end of the transition, and by this strange clipping effect, which I've gathered has something to the parent container's overflow property, which I need as 'hidden' for my use (see example). Please help me figure out how to get this blur effect without the bezel AND the strange clipping at the end of the transition, and while still undergoing a transition duration. For my application purposes, the image being zoomed in 120% to 140% is actually ideal. Thanks!
div {
position:relative;
width:200px;
height:200px;
overflow:hidden;
margin:auto;
background-color: red;
}
img {
position:absolute;
width:140%;
height:140%;
transition-duration: 1s;
left:-20%;
top:-20%;
}
div:hover img {
-webkit-filter: blur(30px);
filter: blur(30px);
transition-timing-function: ease-out;
}
<div id='container'>
<img src = 'https://i.chzbgr.com/full/9112752128/h94C6655E/'>
</div>
One idea is to duplicate the image and consider a blurred version at the bottom of the one that you will blur on hover. This will reduce the bad effect of seing the background.
#container {
position: relative;
width: 200px;
height: 200px;
overflow: hidden;
margin: auto;
background-color: red;
}
#container > div {
position:absolute;
width: 140%;
height: 140%;
left: -20%;
top: -20%;
background-size:0;
}
#container > div:before,
#container > div:after{
content:"";
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background-image:inherit;
background-size:cover;
transition:filter 1s;
transition-timing-function: ease-out;
}
#container> div:before,
#container:hover > div:after {
filter: blur(30px);
}
<div id='container'>
<div style="background-image:url(https://i.chzbgr.com/full/9112752128/h94C6655E/)"></div>
</div>
here's my solution. I just changed left & top property of img to 0. Hope this will help you.
div {
position:relative;
width:200px;
height:200px;
overflow:hidden;
margin:auto;
background-color: red;
transition-duration: 1s;
transition-timing-function: ease-in-out;
}
img {
position:absolute;
width:100%;
left:0;
top:0;
object-fit: cover;
transition-duration: 1s;
transition-timing-function: ease-out;
}
div:hover img {
-webkit-filter: blur(30px);
filter: blur(30px);
transition-timing-function: ease-out;
}
div:hover {
background-color: white;
transition-timing-function: ease-out;
}
<div id='container'>
<img src = 'https://i.chzbgr.com/full/9112752128/h94C6655E/'>
</div>
I have a problem with my website slider images. I set my slider wrap and slider inner frame width to 100% but when I change the screen size the images size does not change. Also I set the images width to max-width:100% and the height of them to auto.
#sliderFrame {
position:relative;
width:100%;
margin: 0 auto; /*center-aligned*/
}
#slider, #slider div.sliderInner {
width:1280px;height:auto;/* Must be the same size as the slider images */
border-radius: 6px;
}
#slider {
background:#fff url(loading.gif) no-repeat 50% 50%;
position:relative;
transform: translate3d(0,0,0);
box-shadow: 0px 1px 5px #999999;
}
#slider a.imgLink, #slider .video {
z-index:2;
cursor:pointer;
position:absolute;
top:0px;left:0px;border:0;padding:0;margin:0;
width:100%;height:100%;
}
#slider div.loading {
max-width:100%; height:auto;
background:transparent url(loading.gif) no-repeat 50% 50%;
filter: alpha(opacity=60);
opacity:0.6;
position:absolute;
left:0;
top:0;
z-index:9;
}
#slider img, #slider>b, #slider a>b {
position:absolute;
border:none;
display:none;
max-width:100%;
height:auto;
}
#slider div.sliderInner {
overflow:hidden;
-webkit-transform: rotate(0.000001deg);/* fixed the Chrome not crop border-radius bug*/
position:absolute;
top:0;
left:0;
max-width:100%;
height:auto;
}
<div id="sliderFrame">
<div id="slider">
<img src="image/Index_1600x500.jpg" alt="#cap1"/>
<img src="image/Index_TrackerPnale_1600x500.jpg"/>
<img src="image/Index_HyundaiSantafe_1600x500.jpg" alt="#cap2"/>
<img src="image/Index_Support.jpg" title="Support Team"/>
<img src="image/Index_SocialMedia_1600x500.jpg" title="Social Medias"/>
</div>
</div>
Your CSS doesn't really say much about your HTML - Also, we have no clue on what you really mean by slider - But follow this fiddle: https://jsfiddle.net/p3r1x5sj/ and see the very minimal CSS you're looking for.
#sliderFrame {
width:100%;
height:100px;
position:relative;
}
#sliderFrame #slider {
width:100%;
height:100%;
position:relative;
background:#fff url(loading.gif) no-repeat 50% 50%;
box-shadow: 0px 1px 5px #999999;
}
#sliderFrame #slider img {
width:100%;
position:absolute;
top:0;
left:0;
}
The img tags are what you have to control. Also, unless you crop the images using overflow:hidden; on your outermost container, the images may be all different heights. In this case you may want to consider using divs with background-images
Sorry for my english.
I have a problem. I need to create a DIV inside another DIV, which has to have a white background. I tried using skew, but It didnt work well.
Here is an image:
There are at least several ways to achieve this, however the simplest way may be using linear-gradient background. Its quality is not really good compared with others but it's totally acceptable.
Try this:
div {
width:600px;
height:300px;
background:teal;
border:1px solid teal;
}
.top {
width:100%;
height:100px;
font-size:25px;
padding-left:30px;
background:linear-gradient(175deg, white 60%, transparent 62%);
border:none;
box-sizing:border-box;
}
HTML:
<div>
<div class='top'>Custom<br/>Home</div>
</div>
Demo.
You can do that with a pseudo element and transform rotate :
DEMO
HTML :
<div id="header">
Custom<br/>
Home
</div>
<div id="content"></div>
CSS :
#header{
background:#fff;
position:relative;
height:50px;
z-index:1;
font-size:30px;
padding-left:10%;
}
#header:before{
content:'';
position:absolute;
bottom:0;
right:0;
width:110%;
height:1000%;
background:inherit;
z-index:-1;
border-bottom:2px solid #636A6E;
-webkit-backface-visibility: hidden; /* to fix pixelisation in chrome */
-ms-transform-origin:100% 100%;
-webkit-transform-origin:100% 100%;
transform-origin:100% 100%;
-webkit-transform: rotate(-5deg);
-ms-transform: rotate(-5deg);
transform: rotate(-5deg);
}
#content{
min-height:500px;
background:#778385;
}
Since you need the border in your diagonal div, try this:
CSS:
.logo {
width:110%;
height:147px;
top:-10%;
left:-14px;
border:2px solid black;
position:absolute;
background:#fff;
transform:rotate(-7deg);
-ms-transform:rotate(-7deg);
/* IE 9 */
-webkit-transform:rotate(-7deg);
/* Opera, Chrome, and Safari */
}
.container {
width:100%;
height:612px;
overflow:hidden;
background:#7b8284;
position:relative;
}
.inner {
position:absolute;
height:200px;
transform:rotate(7deg);
-ms-transform:rotate(7deg);
/* IE 9 */
-webkit-transform:rotate(7deg);
/* Opera, Chrome, and Safari */
padding:20px 90px;
top:30%;
font-size:30px;
}
HTML:
<div class="container">
<div class="logo">
<div class="inner">My Logo</div>
</div>
</div>
Demo: http://jsfiddle.net/lotusgodkk/BKfe9/1/
You can modify the top,left,font-size,background-color,transform, border as per your need
If you want to do it in pure CSS I would recommend using the transform: rotate(xxx) feature of CSS3. I've created a JS-Fiddle that will help you get started (not the best solution...), it is not based on your fiddle: http://jsfiddle.net/syTu7/
I think I understand your question, I think my example will help
HTML
<div class="wrapper">
<div class="innter">some text</div>
</div>
CSS
.wrapper {
position: relative;
width: 960px;
margin: 0 auto;
background: #ddd;
min-height: 100%;
height: 800px;
}
.innter {
height: 500px;
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: #ececec;
}
In HTML,
<div class="wrapper">
<div class="inner">some content</div>
</div>
In CSS,
.inner {
background: #fff;
}
i set the opacity property of the outer div to the .5,
and i set the inner div's opacity value to be 1
but it still to be transparent at all
here is the sample code:
HTML:
<div id="div1">
<div id="div2">
<div id="div3"></div>
</div>
</div>
CSS:
#div1{
background: black;
opacity:.5;
width:300px;
height:300px;
}
#div2{
background:white;
width:150px;
height:150px;
opacity: 1;
}
#div3{
display: block;
width: 50px;
height: 50px;
opacity: 1;
background: black;
}
so where is the problem?
or anything i have miss ?
help me!
This is a common misconception about CSS, you can't set opacity on a parent and then prevent it from affecting its children. What you need is to set an alpha color for #div1:
#div1{
background: rgba(0,0,0,0.5);
width:300px;
height:300px;
}