Css hover with box shadow is not working as i required - html

<style>
.ui-state-active {
color: #fff;
background:red;
#box-shadow: inset -7px 7px 9px -7px #236c4d;
width:50px;
height:50px;
}
.ui-state-active:hover{
box-shadow: inset 15px 7px 9px -7px #fff;
box-shadow: inset -7px 7px 9px -7px #fff;
}
</style>
<div class="ui-state-active">18
</div>
I need something like this, when i hovered on a div it show a transformed triangle on top right like shown in image, I just explained my requirement as image for clear clarification

You can do it with pseudo elements :before or :after
.ui-state-active {
color: #fff;
background:red;
width:50px;
height:50px;
position: relative;
}
.ui-state-active:hover:after{
content: '';
position: absolute;
top: 3px;
right: 3px;
border: solid 10px white;
border-color: white white transparent transparent;
}
<div class="ui-state-active">18
</div>

I wouldn't use a box-shadow, I'd use a pseudo-element.
There's a couple of way to do that.
1. A position, rotated pseduo-element:
span {
display: block;
width: 3em;
height: 3em;
line-height: 3em;
text-align: center;
background: #f00;
color: white;
font-weight: bold;
margin: 3em auto;
overflow: hidden;
position: relative;
}
span::after {
content: '';
position: absolute;
width: 100%;
height: 100%;
background: orange;
top: -100%;
left: 100%;
transform: rotate(45deg) translate(0%, 0%);
transition: transform .35s ease;
}
span:hover::after {
transform: rotate(45deg) translate(0%, 50%)
<span>16</span>
2. Alternatively, a psuedo-element made entirely of borders
div {
display: block;
width: 3em;
height: 3em;
line-height: 3em;
text-align: center;
background: #f00;
color: white;
font-weight: bold;
margin: 3em auto;
overflow: hidden;
position: relative;
}
div::after {
content: '';
position: absolute;
width: 0;
height: 0;
top: 0;
right: 0;
border-style: solid;
border-color: orange orange transparent transparent;
border-width: 0px;
transition: border-width .35s ease;
}
div:hover::after {
border-width: 12px;
}
<div>16</div>

Try this out, :)
HTML
<div class="date">
<div class="sideflip"></div>
18
</div>
CSS
.date
{
width:80px;
height:80px;
border:1px solid #000000;
text-align:center;
font-size:65px;
font-family: "Century Gothic", CenturyGothic, AppleGothic, sans-serif;
background:red;
color:#ffffff;
position:relative;
overflow:hidden;
}
.sideflip
{
width:50px;
height:50px;
font-size:1px;
position:absolute;
-ms-transform: rotate(-50deg);
-webkit-transform: rotate(-50deg);
transform: rotate(-50deg);
margin-left:160px;
margin-top:-130px;
background:#ffffff;
-webkit-transition: all 0.5s;
transition: all 0.5s;
}
.date:hover .sideflip
{
margin-left:60px;
margin-top:-30px;
}
.date:hover
{
cursor:pointer;
}

Related

CSS hover transition, width from the center

I was wondering how I would make an object wider from the center, instead of from the left.
Here is my HTML:
<html>
<body>
<a href='#'>Hover</a>
</body>
</html>
and here is my CSS:
body{
margin:0;
padding:0;
background-color:#262626;
}
a{
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
padding:10px 25px;
border:2px solid white;
text-decoration:none;
color:white;
font-family:verdana;
font-size:27px;
text-transform:uppercase;
letter-spacing:4px;
transform:1s;
}
a::before{
content:'';
position:absolute;
height:100%;
width:0%;
top:0;
left:50%;
z-index:-1;
background-image:linear-gradient(45deg, #eea949,#ff3984);
transition:.5s;
}
a:hover::before{
width:100%;
}
instead of widening from the center on hover, it widens from the left. I have tried adding transform: translate(-50%, 0); to the a:hover::before in the css, it kind of worked, but it made it a little wobbly (I don't know how to explain it). Can someone help with this?
You can do it with only background:
body {
margin: 0;
padding: 0;
background-color: #262626;
}
a {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 10px 25px;
border: 2px solid white;
text-decoration: none;
color: white;
font-family: verdana;
font-size: 27px;
text-transform: uppercase;
letter-spacing: 4px;
transition: 0.5s;
background: linear-gradient(45deg, #eea949, #ff3984) center/0% 100% no-repeat;
}
a:hover {
background-size: 100% 100%;
}
<a href='#'>Hover</a>
I think I solved it. I added a ::after to the element, rotated the gradient, and made the ::after go left 50%, while the ::before went right 50%. Like this:
body {
margin: 0;
padding: 0;
background-color: #262626;
}
a {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 10px 25px;
border: 2px solid white;
text-decoration: none;
color: white;
font-family: verdana;
font-size: 27px;
text-transform: uppercase;
letter-spacing: 4px;
transform: 1s;
}
a::before {
content: '';
position: absolute;
height: 100%;
width: 0%;
top: 0;
left: 50%;
z-index: -1;
border: none;
outline: none;
background-image: linear-gradient(45deg, #eea949, #ff3984);
transition: .5s;
}
a::after {
content: '';
position: absolute;
height: 100%;
width: 0%;
top: 0;
right: 50%;
z-index: -1;
background-image: linear-gradient(135deg, #ff3984, #eea949);
border: none;
outline: none;
transition: .5s;
}
a:hover::before {
width: 50%;
}
a:hover::after {
width: 50%;
}
<html>
<body>
<a href='#'>Hover</a>
</body>
</html>
I hope this helps. If you want to see a JSFiddle, click here.
Add these styles to the body element to center the link. Then remove the position: absolute; top: 0 and left:0; from the link (they would be redundant with flex) and add this style to make it parent.
body{
display: flex;
justify-content: center;
align-items: center;
}
a{
position: relative
transition: all .1s;
}
and then add transform: translateX(-50%); on the a:hover::before{} as you wanted.
This format I found to not have a wobble.

Overflow: hidden not being filled 100% by psuedo element?

It's hard to explain this. I'm trying to do something like this:
https://codepen.io/pen/yLBaJOq
.button {
position: relative;
display: inline-block;
padding: 20px;
line-height: 10px;
font-size: 12px;
font-weight: bold;
text-transform: uppercase;
border: 9px solid black;
border-radius: 55px;
transition: all 0.35s ease-in-out;
color: black;
cursor: pointer;
overflow: hidden;
z-index: 1;
background-color: transparent;
}
.button:before {
content: '';
display: block;
position: absolute;
background-color: red;
left: 50%;
top: 50%;
transform: translate(-50%, -50%) rotate(-30deg);
transform-origin: center;
width: calc(100% + 30px);
height: 0;
padding-top: 0%;
transition: all 0.35s ease-in-out;
z-index: -1;
}
.button:hover {
color: #fff;
border: 9px solid red;
}
.button:hover:before {
padding-top: 200%;
}
But there's a thin line between the border and the element. Like the pseudo-element :before is not filling out the parent 100%. Image of what I mean:
It's happening in all browsers I'm trying (Chrome, FF, Safari, all Mac).
So I'm wondering if I can prevent this from happening, while still keeping a similar hover effect.
I could of course just use the transition on the background color and scrap the idea with the pseudo-element as the background.
Add background color to the button hover.
Change:
.button:hover {
color: #fff;
border: 9px solid red;
}
to:
.button:hover {
color: #fff;
border: 9px solid red;
background-color: red;
}
.button {
position: relative;
display: inline-block;
padding: 20px;
line-height: 10px;
font-size: 12px;
font-weight: bold;
text-transform: uppercase;
border: 9px solid black;
border-radius: 55px;
transition: all 0.35s ease-in-out;
color: black;
cursor: pointer;
overflow: hidden;
z-index: 1;
background-color: transparent;
}
.button:before {
content: '';
display: block;
position: absolute;
background-color: red;
left: 50%;
top: 50%;
transform: translate(-50%, -50%) rotate(-30deg);
transform-origin: center;
width: calc(100% + 30px);
height: 0;
padding-top: 0%;
transition: all 0.35s ease-in-out;
z-index: -1;
}
.button:hover {
color: #fff;
border: 9px solid red;
background: red;
}
.button:hover:before {
padding-top: 200%;
}
<div class="button">WOAH</div>

How to add box shadow around the below shape [duplicate]

This question already has answers here:
CSS box shadow around a custom shape?
(3 answers)
Closed 5 years ago.
Hi Guys i am trying to add a box shadow around the custom shape created using css
like the below image
body{
padding:50px
}
div{
height: 45px;
width: 209px;
float: left;
color: #fff;
line-height: 45px;
text-align: center;
position: relative;
font-family: Arial;
font-weight: bold;
font-size: 16px;
background-color: #50b3cf;
}
div::after{
position: absolute;
z-index: 2;
content: "";
width: 0;
height: 0;
border-top: 22.5px solid transparent;
border-bottom: 22.5px solid transparent;
right: 1px;
transform: translateX(100%);
border-left: 22.5px solid #50b3cf;
}
<div></div>
Declare values for the pseudo-element width & height
properties;
purge the borders;
then rotate the pseudo-element in question;
now apply box-shadow as required;
grab a nice cold one;
body{
padding:50px
}
div{
height: 45px;
width: 209px;
float: left;
color: #fff;
line-height: 45px;
text-align: center;
position: relative;
font-family: Arial;
font-weight: bold;
font-size: 16px;
background-color: #50b3cf;
box-shadow: 0px 0px 5px 3px #000000;
}
div::after {
position: absolute;
z-index: 2;
content: "";
left: 100%;
width: 32px;
height: 32px;
background: #50b3cf;
transform: rotate(46deg);
transform-origin: 0 0;
box-shadow: 3px -3px 5px 0px #000000;
}
div::before { /* ver 2.0 Patch */
content: "";
position: absolute;
background: #50b3cf;
top: 0;
bottom: 0;
width: 25px;
right: 0;
z-index: 9;
}
<div></div>
.box{
border:1px solid white;
width:400px;
height:150px;
margin-left:40px;
box-shadow: 0 0 9px 3px rgba(0,0,0,0.5);
}
.arrow {
width: 100px;
height: 100px;
position: relative;
top:20px;
left:-100px;
overflow: hidden;
box-shadow: 0 10px 10px -17px rgba(0,0,0,0.5);
transform: rotate(270deg);
}
.arrow:after {
content: "";
position: absolute;
width: 50px;
height: 50px;
background: white;
transform: rotate(45deg);
top: 76px;
left: 25px;
box-shadow: -2px -2px 9px 0px rgba(0,0,0,0.5);
}
<div class="box">
<div class="arrow"></div>
</div>
Try this code
Maybe this what you are looking to do.
The first one with box shadow, the second one doesn't has box shadow but you can add it using this code box-shadow: 0px 0px 6px 0px #000;in class "arrow-r"
<style type="text/css">
.main-box{
position: relative;
padding: 0 35px 90px;
}
.box{
font-size: 20px;
position: relative;
display: inline-block;
clear: both;
margin-bottom: 8px;
padding: 13px 14px;
vertical-align: top;
border-radius: 5px;
}
.arrow-l {
float: left;
color: #fff;
background-color: #08abf4; box-shadow: 0px 0px 6px 0px #000;
}
.arrow-r {
float: right;
color: #1a1a1a;
background-color: #e2e2e2;
}
.box:before{
position: absolute;
top: 24px;
width: 8px;
height: 6px;
content: '\00a0';
-webkit-transform: rotate(30deg) skew(-36deg);
transform: rotate(30deg) skew(-36deg);
}
.box.left:before {
left: -4px;
background-color: #08abf4;
}
.box:before{
position: absolute;
top: 21px;
width: 8px;
height: 6px;
content: '\00a0';
-webkit-transform: rotate(30deg) skew(-36deg);
transform: rotate(30deg) skew(-36deg);
}
.box.right:before {
right: -4px;
background-color: #e2e2e2;
}
</style>
<div class="main-box">
<div class="box arrow-l left">
I'm Liam Lababidi
</div>
<div class="box arrow-r right">
What about u?
</div>
</div>
You want to use box-shadow: 10px 10px 5px #888888; for this. Each px indicates what side and the # indicates the color.
body{
padding:50px
}
div{
height: 45px;
width: 209px;
float: left;
color: #fff;
line-height: 45px;
text-align: center;
position: relative;
font-family: Arial;
font-weight: bold;
font-size: 16px;
background-color: #50b3cf;
box-shadow: 0px 10px 5px #888888;
}
div::after{
position: absolute;
z-index: 2;
content: "";
width: 0;
height: 0;
border-top: 22.5px solid transparent;
border-bottom: 22.5px solid transparent;
right: 1px;
transform: translateX(100%);
border-left: 22.5px solid #50b3cf;
}
<div></div>

create a css format with socil media icon [duplicate]

I'm trying to draw a line using CSS and show text/image in the middle of the line.
.featured-images {
color: #666666;
border: 2px solid #333333;
}
<p class="featured-images">Featured</p>
This is what I want to do:
and
Wrap the text inside a span and use a :pseudo-element for the line.
Position the line(:pseudo-element) behind the span using z-index: -1, so that you could move around the text without having to worry about the line.
.featured-images {
position: relative;
color: #666666;
border: 2px solid #333333;
padding: 0 10px 0 30px;
}
.featured-images span {
color: #666666;
background: white;
padding: 0 10px;
}
.featured-images:after {
content: '';
position: absolute;
width: 100%;
height: 2px;
background: #666666;
left: 0;
top: 50%;
transform: translateY(-50%);
z-index: -1;
}
<p class="featured-images"><span>Featured</span></p>
Replicating the following:
You could use repeating-linear-gradient to do this.
body {
background: #E7EAE3;
}
.featured-images {
position: relative;
color: #666666;
padding: 0 10px 0 30px;
overflow: hidden;
}
.featured-images span {
color: #517575;
background: white;
padding: 0 10px;
}
.featured-images:after {
content: '';
position: absolute;
width: 120%;
height: 100%;
background: -webkit-repeating-linear-gradient(180deg, #463A3A 10px, #F2F2F2 10px, #F2F2F2 11px, #463A3A 11px, #463A3A 20px) repeat-x;
background: -moz-repeating-linear-gradient(180deg, #463A3A 10px, #F2F2F2 10px, #F2F2F2 11px, #463A3A 11px, #463A3A 20px) repeat-x;
background-size: 10px 31px;
margin-left: -30px;
transform: skew(-45deg);
left: 0;
z-index: -1;
}
<p class="featured-images"><span>Featured</span>
</p>
Using image instead of text.
.featured-images {
position: relative;
color: #666666;
border: 2px solid #333333;
padding: 0 10px 0 30px;
}
.featured-images span {
display: block;
width: 80px;
height: 13px;
background: url(http://lorempixel.com/80/13) no-repeat white 10px 0;
padding: 0 10px;
}
.featured-images:after {
content: '';
position: absolute;
width: 100%;
height: 2px;
background: #666666;
left: 0;
top: 50%;
transform: translateY(-50%);
z-index: -1;
}
<p class="featured-images"><span></span></p>
Something like this? JSFiddle
CSS:
.featured-images {
color: #666666;
}
p span {
margin:0;padding: 0 10px;
background: #FFFFFF;
display: inline-block;
}
p {
padding-left: 20px;
position: relative;
z-index: 2;
}
p:after {
content: "";
position: absolute;
top: 50%;
left: 0;
right: 0;
border-top: solid 1px #666666;
z-index: -1;
}
Demo 1
:root{padding: 40px}
p{
position: relative;
margin:40px auto;padding:0 10px;
background:white;
display:inline-block;
}
p:before,p:after{
content:"";
position:absolute;
z-index:-1;
right:0
}
p:before{
top:-4px;
left: -24px;
height: 24px;
width: 480px;
border:solid 1px #666666
}
p:after{
top: 50%;
width: 466px;
left: -16px;
border-top: solid 1px #666666
}
<p class="featured-images">Featured</p>
Use Pseudo element
:root{padding: 40px}
p{
position: relative;
margin:40px auto;padding:0 10px;
background:white;
display:inline-block;
}
p:before,p:after{
content:"";
position:absolute;
z-index:-1;
left:-14px;
right:0;
width: 480px
}
p:before{
top:-4px;
height: 24px;
border:solid 1px #666666
}
p:after{
top:50%;
border-top:solid 1px #666666
}
<p class="featured-images">Featured</p>
Demo 2
p{
position: relative;
margin:0;padding:0 10px;
background:white;
display:inline-block;
}
p:after{
content:"";
position:absolute;
top:50%;
left:-14px;
right:0;
width: 100vw;
border-top:solid 1px #666666;
z-index:-1;
}
<p class="featured-images">Featured</p>
Update
:root{padding: 40px}
p{
position: relative;
margin:40px auto;padding:0 10px;
background:white;
display:inline-block;
}
p:before,p:after{
content:"";
position:absolute;
z-index:-1;
right:0
}
p:before{
top:-4px;
left: -24px;
height: 24px;
width: 480px;
border:solid 1px #666666;
background-color: gray;
background-image: repeating-linear-gradient(-45deg, transparent, transparent 2px, rgba(255,255,255,.5) 2px, rgba(255,255,255,.5) 6px)
}
}
p:after{
top: 50%;
width: 466px;
left: -16px;
border-top: solid 1px #666666
}
<p class="featured-images">Featured</p>
Result http://jsfiddle.net/p8jdzqvL/embedded/result/
<div style="height: 2px; background-color: black; text-align: center">
<span style="background-color: white; position: relative; top: -0.5em;">
Stay Connected
</span>
</div>

Links not working on Parallax design

I have a link in the final div (slide4) and it is not working. I've messed around with z-index and positioning but that didn't work.
This is my first time messing around with a parallax design and I'm using a template to familiarize myself with it, but I hit a snag in this and can't figure it out.
Here's the codepen: http://codepen.io/anon/pen/bdGcI
CSS:
<style type="text/css">
html {
height: 100%;
overflow: hidden;
}
`body {
margin:0;
padding:0;
perspective: 1px;
transform-style: preserve-3d;
height: 100%;
overflow-y: scroll;
overflow-x: hidden;
font-family: Oswald;
}`body {
margin:0;
padding:0;
perspective: 1px;
transform-style: preserve-3d;
height: 100%;
overflow-y: scroll;
overflow-x: hidden;
font-family: Oswald;
}
a:link {
text-decoration: none;
color: #fff;
}
a:visited {
text-decoration: none;
color: #ccc;
}
a:hover {
text-decoration: underline;
color: #B22222;
}
a:active {
text-decoration: underline;
}
h1 {
font-size: 550%
}
h2 {
font-size: 250%
}
p {
font-size: 140%;
line-height: 150%;
color: #333;
}
p2 {
font-size: 300%;
line-height: 150%;
color: #fff;
}
.slide {
position: relative;
padding: 25vh 10%;
min-height: 100vh;
width: 100vw;
box-sizing: border-box;
box-shadow: 0 -1px 10px rgba(0, 0, 0, .7);
transform-style: inherit;
}
img {
position: absolute;
top: 50%;
left: 35%;
width: 320px;
height: 240px;
transform: translateZ(.25px) scale(.75) translateX(-94%) translateY(-100%) rotate(2deg);
padding: 1px;
border-radius: 10px;
background: rgba(240,230,220, .7);
box-shadow: 0 0 1px rgba(0, 0, 0, .7);
}
img:last-of-type {
transform: translateZ(.4px) scale(.6) translateX(-104%) translateY(-40%) rotate(-5deg);
}
.slide:before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left:0;
right:0;
}
.title {
width: 50%;
padding: 2%;
border-radius: 5px;
background: rgba(240,230,220, .7);
box-shadow: 0 0 8px rgba(0, 0, 0, .7);
}
.slide:nth-child(2n) .title {
margin-left: 0;
margin-right: auto;
}
.slide:nth-child(2n+1) .title {
margin-left: auto;
margin-right: 0;
}
.slide, .slide:before {
background: 50% 50% / cover;
}
.header {
text-align: center;
font-size: 175%;
color: #fff;
text-shadow: 0 4px 4px #000;
}
.header2 {
text-align: center;
font-size: 175%;
color: #fff;
}
#title {
background-image: url("bg2");
background-attachment: fixed;
}
#slide1:before {
background-image: url("bg3");
transform: translateZ(-1px) scale(2);
z-index:-1;
}
#slide2 {
background-image: url("bg4");
background-attachment: fixed;
}
#slide3:before {
background-image: url("bgbg");
transform: translateZ(-1px) scale(2);
z-index:-1;
}
#slide4 {
background: #222;
}
</style>
</head>
HTML in question:
<div id="slide3" class="slide">
<div class="title">
<h2>Music</h2>
<p>words words words.</p>
</div>
</div>
<div id="slide4" class="slide header2">
Final Page Link.
</div>
Because :before pseudo class is causing an overlay over the content as you have written
.slide:before {
content: "";
position: absolute;
/*top:0;*/ /*remove this */
bottom: 0;
left:0;
right:0;
}
Code pen Demo
You have .slide:before with position:absolute; if you remove that it will work, so your problem is that Absolute position is Over the Link and content. If you add position:relative; to ahref or add relative to new Container inside #slide4, it will work..
1http://codepen.io/anon/pen/HGIiF/