How to add 'shine' overlay to a div? - html

How can I add a nice overlay like the one in the following image?
Consider the following HTML, how would I add an overlay like that? I know I can use a gradient on top of it, and apply it diagonally, but can I curve it as well?
<div class="photostrip">
<div class="overlay" />
<img src="http://i.imgur.com/a21tM.jpg" />
<img src="http://i.imgur.com/a21tM.jpg" />
<img src="http://i.imgur.com/a21tM.jpg" />
</div>
Here's something I've tried (I've oversaturated the overlay so it's easily seen), but it's not quite the shape I'm looking for.
body { background-color: #4b74db; }
.photostrip {
margin: 0 auto;
width: 185px;
background-color: #000;
box-shadow: 0px 3px 7px 3px #333;
padding: 7px;
padding-bottom: 2px;
position: relative;
.overlay {
height: 100%;
width: 100%;
position: absolute;
top: 0px;
left: 0px;
border-bottom-right-radius: 200px 403px;
/* This adds the nice overlay. */
background: -webkit-linear-gradient(top, rgba(255,255,255,0.60) 0%,rgba(255,255,255,0.05) 100%);
}
img {
display: block;
width: 175px;
height: 120px;
margin: 0 auto;
margin-top: 6px;
margin-bottom: 11px;
}
}

Does something like this work for you: http://codepen.io/defo550/pen/Fcsxo
.photostrip {
margin: 0 auto;
width: 185px;
background-color: #fff;
box-shadow: 0px 3px 7px 3px #333;
padding: 7px;
padding-bottom: 2px;
/* Remove default list stylings*/
list-style: none;
/* provide a position context for our pseudo element */
li {
position: relative;
}
img {
display: block;
width: 175px;
height: 120px;
margin: 0 auto;
margin-top: 6px;
margin-bottom: 11px;
}
}
/* overlay styles
create pseudo element
*/
.photostrip li:after {
content: "";
position: absolute;
/* position above img */
z-index: 5;
width: 175px;
height: 120px;
top: 0;
left: 5px;
/* overlay styles */
background: linear-gradient(135deg, rgba(255,255,255,0.33) 0%,rgba(255,255,255,0.33) 60%,rgba(255,255,255,0) 61%,rgba(255,255,255,0) 100%);
}
<ul class="photostrip">
<li><img /></li>
<li><img /></li>
<li><img /></li>
</ul>
I put your images in an unordered list and then created a pseudo-element on the li (that wraps each image) that has a background gradient with the desired effect ( or close ) of your image above.
You could also target each li separately in the CSS to change up the background gradient.

i think this close to what you are looking for you just have to play with the numbers
http://codepen.io/anon/pen/GDvju
i just added another layer and gave it a top left radius
body { background-color: #4b74db; }
.photostrip {
margin: 0 auto;
width: 185px;
background-color: #000;
box-shadow: 0px 3px 7px 3px #333;
padding: 7px;
padding-bottom: 2px;
position: relative;
.overlay {
height: 100%;
width: 100%;
position: absolute;
top: 0px;
left: 0px;
/* This adds the nice overlay. */
background: -webkit-linear-gradient(top, rgba(255,255,255,0.60) 0%,rgba(255,255,255,0.05) 100%);
}
.overlay2 {
height: 100%;
width: 50%;
position: absolute;
right: 0px;
border-top-left-radius: 300px 600px;
background: -webkit-linear-gradient(top, rgba(0,0,0,0.60) 0%,rgba(0,0,0,0.05) 100%);
}
img {
display: block;
width: 175px;
height: 120px;
margin: 0 auto;
margin-top: 6px;
margin-bottom: 11px;
}
}

Related

Is it possible to add image as box shadow with css?

Is it possible to add image as box shadow, for example to put image with dots instead of standard shadow?
https://i.stack.imgur.com/DOJGh.png
or somehow to replace shadow from picture with dots?
to get effect like this on picture down here
http://prntscr.com/fvjnht
Did you want something like this? It's not exactly box-shadow, but it imitates it.
You can set whatever image you like as a background for .image::after.
html, body {
margin: 0;
}
body {
width: 100vw;
height: 100vh;
}
.contain {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.image{
position: relative;
width: 200px;
height: 200px;
background-image: url(http://via.placeholder.com/200x200);
}
.image::after {
content: '';
background: linear-gradient(to bottom, #333, red);
position: absolute;
width: 100%;
height: 100%;
bottom: -10px;
right: -10px;
z-index: -1;
}
<div class="contain">
<div class="image"></div>
</div>
I think this is exactly what you are looking for:
body {
background: black;
}
#logo {
width: 200px;
height: 200px;
display: block;
position: relative;
}
#logo::after {
content: "";
background: url("https://rfclipart.com/image/big/3f-a9-1a/red-dotted-halftone-background-Download-Royalty-free-Vector-File-EPS-183199.jpg");
opacity: 0.4;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
border-radius: 50%;
z-index: -1;
}
img {
width: 90%;
height: 90%;
padding: 5%;
display: block;
float: left;
border-radius: 50%;
box-shadow: 0px 0px 40px #ccc;
-moz-box-shadow: 0px 0px 40px #ccc;
-webkit-box-shadow: 0px 0px 40px #ccc;
}
<div id="logo">
<img src="http://icons.iconarchive.com/icons/graphicloads/colorful-long-
shadow/256/User-icon.png" alt=""/>
</div>
Kind of like this?
.image_carousel img {
margin-right: 14px;
display: block;
float: left;
box-shadow: 3px 3px 1px #ccc;
-webkit-box-shadow: 3px 3px 1px #ccc;
-moz-box-shadow: 3px 3px 1px #ccc;
}
<div class="image_carousel"><img src="//placehold.it/300/f80/fff" alt=""/></div>
Credit goes to Joseph Marikle.
Like this?
span {
border: 2px dotted red;
display: inline-block;
}
img {
padding: 0;
margin: 0;
display: block;
}
<span class="dotted-border"><img src="http://placehold.it/200"/></span>

Making rounded triangle shape using CSS

I have been trying to create this shape in the bottom left and top right corners of the page. Unfortunately, I have not been able to create the desired look the closest that I have been able to achieve is a pie shape with the following code:
<style>
/* css code that will create, color, and shape
the first accent color area */
#colorAreaOne{
width: 700px;
height: 700px;
background: #3333ff;
opacity: 0.8;
border-radius: 0 700px 0 0;
-moz-border-radius: 0 700px 0 0;
-webkit-border-radius: 0 700px 0 0;
position: fixed;
bottom: 0px;
left: 0px;
}
/* css code that will create, color, and shape
the second accent color area */
#colorAreaTwo{
width: 700px;
height: 700px;
background: #3333ff;
opacity: 0.8;
border-radius: 0 0 700px; 0;
-moz-border-radius: 0 0 700px 0;
-webkit-border-radius: 0 0 700px 0;
position: fixed;
top: 0px;
right: 0px;
}
</style>
If anyone has any information it would be much appreciated. Thank you!
A radial-gradient
div {
width: 700px;
height: 700px;
margin: 1em auto;
background-image: radial-gradient(circle at 100% 0, transparent 0%, transparent 700px, black 700px);
}
<div></div>
You may use a square and use a round pseudo to fill parts of it with a shadow
div {
height:50vw;
width:50vw;
bottom:0;
position:fixed;
overflow:hidden;
}
div:before {
content:'';
display:block;
height:100%;
border-radius:0 0 0 50% ;
box-shadow:0 0 0 50vw turquoise;
<div></div>
border-radius: 50%; overflow: hidden;
.shape{
width: 400px;
height: 400px;
overflow: hidden;
position: relative;
}
.shape:after{
content: "";
position: absolute;
left: -100%;
bottom: -100%;
width: 200%;
height: 200%;
-webkit-border-radius: 50%;
border-radius: 50%;
border: 400px solid;
<div class="shape"></div>
Here is one quick solution that will work if pseudo element is same color as background.
.el {
width: 200px;
height: 200px;
background: black;
position: relative;
overflow: hidden;
margin: 50px;
}
.el:before {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 200%;
height: 200%;
background: white;
border-radius: 50%;
}
<div class="el"></div>

Creating angled shape using CSS

Is it possible to create a shape like this using the CSS border?
I saw some other stack overflow posts regarding making some border modifications, but nothing specifically like this. Can someone point me in the right direction?
Thanks
Based on https://css-tricks.com/examples/ShapesOfCSS/:
#base {
background: red;
display: inline-block;
height: 30px;
margin-left: 20px;
margin-top: 55px;
position: relative;
width: 200px;
text-align: center;
}
#base:before {
border-bottom: 15px solid red;
border-left: 100px solid transparent;
border-right: 100px solid transparent;
content: "";
height: 0;
left: 0;
position: absolute;
top: -15px;
width: 0;
}
<div id="base"><span>BACK TO TOP</span></div>
Just modify the width and height for your needs, it is really easy.
You can create this shape using css :before and :after selectors:
#back {
background: #fff;
border:1px solid #333;
display: inline-block;
height: 20px;
margin-left: 20px;
margin-top: 55px;
position: relative;
width: 120px;
text-align: center;
}
#back:before {
border-bottom: 15px solid #fff;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
content: "";
height: 0;
left: 0;
position: absolute;
top: -15px;
width: 0;
z-index:2;
}
#back:after {
border-bottom: 15px solid #333;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
content: "";
height: 0;
left: 0;
position: absolute;
top: -16px;
width: 0 ;
z-index:1;
}
<div id="back"><span>Back to Top</span></div>
Fully adaptive and transparent...
* {
margin: 0;
padding: 0;
}
body {
position: relative;
width: 100vw;
height: 100vh;
background-image: linear-gradient(rgba(0, 0, 0, .7) 0, rgba(0, 0, 0, .7) 100%), url('http://beerhold.it/1024/600');
background-repeat: no-repeat;
background-size: cover;
}
.border-arrow-top {
display: inline-block;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
color: white;
text-align: center;
font-size: 6vh;
text-transform: uppercase;
padding: 0 10vw;
padding-bottom: 2vh;
border: 3px solid white;
border-top: none;
position: relative;
}
.border-arrow-top:before,
.border-arrow-top:after {
content: '';
position: absolute;
top: 0%;
border-top: 3px solid white;
width: 50%;
}
.border-arrow-top:before {
left: 0;
transform-origin: -3px -50%;
/* x-coord: -[size of border] */
transform: skewy(-10deg);
}
.border-arrow-top:after {
right: 0;
transform-origin: calc(100% + 3px) -50%;
/* x-coord: 100% + size of border */
transform: skewy(10deg);
}
<div class="border-arrow-top">
Back to Top
</div>
I had written a tutorial for the same, arrow heads and triangles with CSS which can be read here: http://time2hack.com/2014/10/triangles-and-arrow-heads-css.html.
The trick works on the basis of borders and their colors. The direction in which arrow has to point; border of that side can be 0 and rest of the sides will create the arrow head.
The main role will be of opposite side border; if arrow has to point to top, border-bottom will create the arrow and rest can be transparent and if arrow has to point to bottom, the border-top will be of some color and other will be transparent. Similar is for arrow pointing left and right.
The transparent color will work fine in all browser except IE8 and below; for this you can set the color to the matching background, so that it is not visible.
By customizing the fiddle http://jsfiddle.net/95Xq8/ The given below is the output
Check the fiddle
.arrow-wrap{ width:125px; margin:auto; padding:100px 0;}
.arrow-button {
width: 125px;
height: 50px;
line-height: 50px;
position: relative;
background: #f00;
text-align: center; text-decoration:none; color:#000; display:block;
color:#fff;
}
.arrow-tip {
display: block;
width: 101px;
height: 115px;
margin: 0;
-webkit-transform: rotate(45deg) skew(-18deg,-23deg);
}
.arrow-tip-container {
display: block;
width: 125px;
height: 40px;
position: absolute;
top: -40px;
left: 0px;
overflow: hidden;
}
.arrow-tip-grad {
display: block;
width: 100%;
height: 100%;
background: red;
}
<div class="arrow-wrap">
<a href="#" class="arrow-button">Back to top
<span class="arrow-tip-container">
<span class="arrow-tip">
<span class="arrow-tip-grad"></span>
</span>
</span>
</a>
</div>

I am unable to achieve click effect when hover over image

The sample div hovers fine however the background image doesn't move.
The div hovers fine but the image in the background stays at the same position.
What I am trying to achieve is when you hover over the div it moves like it clicks, but the background image in the div doesn't seems to move at all. I want the div and the background to move like real button click.
Fiddle link: http://jsfiddle.net/jackJoe/YhDXm/.
.sample {
width: 220px;
height: 220px;
position: absolute;
overflow: hidden;
margin: 180px;
border-radius: 10px;
-o-border-radius: 10px;
-ms-border-radius: 10px;
-webkit-border-radius: 10px;
background: url(http://static.adzerk.net/Advertisers/2362.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
background-position: 188px 188px;
}
.sample > header {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
padding: 20px 10px;
background: inherit;
background-attachment: fixed;
overflow: hidden;
}
.sample > header::before {
content: "";
position: absolute;
top: -20px;
left: 0;
width: 200%;
height: 200%;
background: inherit;
background-attachment: fixed;
-webkit-filter: blur(4px);
filter: blur(4px);
}
.sample > header::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.25)
}
.sample > header p a {
margin: 0;
color: white;
position: relative;
z-index: 0;
}
.sample:hover {
background-color: #f0eade;
box-shadow: 1px 1px 5px #363024;
-webkit-box-shadow: 1px 1px 5px #363024;
-moz-box-shadow: 1px 1px 5px #363024;
position: relative;
top: 10px;
margin: 180px;
}
<div class="sample">
<header>
<p><a>
Skyscraper
</a>
</p>
</header>
</div>
Your background image stays still because you have background-attachment: fixed; enabled.
From MDN on background-attachment: fixed
This keyword means that the background is fixed with regard to the viewport. Even if an element has a scrolling mechanism, a ‘fixed’ background doesn't move with the element.
Remove your background-attachment statement entirely and change your background-position to 0 0 (or top left) and then you will need to tinker the child elements appropriately.
Fiddle here with adjustments made.
Now that I'm done with that, some supplemental advice:
You should most certainly not do this using top or any other positional properties. These will cause a layout re-calculation on every single hover event (even with position: absolute;) and a paint, at a minimum. If you have a lot of stuff on that page your users may become frustrated or displeased with the stuttering on the page.
Instead, use transform: translate(X, Y); for a very cheap and equally effective move. Here is the fiddle with this incorporated
I found the answer for my question, thanks everyone for the help,
This is fiddle linke: http://jsfiddle.net/YhDXm/1186/
.sample {
width: 220px;
height: 220px;
position: absolute;
overflow: hidden;
margin: 180px;
border-radius: 10px;
-o-border-radius: 10px;
-ms-border-radius: 10px;
-webkit-border-radius: 10px;
background: url(http://static.adzerk.net/Advertisers/2362.jpg);
background-repeat: no-repeat;
background-position: 0 0;
}
.sample > header {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
padding: 20px 10px;
background: inherit;
background-attachment: fixed;
overflow: hidden;
}
.sample > header::before {
content: "";
position: absolute;
top: -20px;
left: 0;
width: 100%;
background: inherit;
background-attachment: fixed;
-webkit-filter: blur(4px);
filter: blur(4px);
}
.sample > header::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.25)
}
.sample > header p a {
margin: 0;
color: white;
position: relative;
z-index: 0;
}
.sample:hover {
box-shadow: 1px 1px 5px #363024;
-webkit-box-shadow: 1px 1px 5px #363024;
-moz-box-shadow: 1px 1px 5px #363024;
position: relative;
top: 10px;
margin: 180px;
}
<div class="sample">
<header>
<p><a>
Skyscraper
</a>
</p>
</header>
</div>

HTML and CSS - Display Images Inside a 'Border' Image

I am currently having an issue with a JavaScript Slider/Slideshow. Essentially, I have 4 images being displayed in the slider. However, I wish to have an image for the border of this slider, so it 'overlays' the images to make it appear like the slider images are inside of this border image.
My HTML code:
<body>
<div id="container">
<div id="frame"></div>
<div id="slides">
<div class="slides_container">
<img src="img/slider/1.jpg" width="954" height="247" alt="Slide 1">
<img src="img/slider/2.jpg" width="954" height="247" alt="Slide 2">
<img src="img/slider/3.jpg" width="954" height="247" alt="Slide 3">
<img src="img/slider/4.jpg" width="954" height="247" alt="Slide 4">
</div>
</div>
</div>
</body>
My CSS code:
/*
Page style
*/
body {
}
#container {
width: 964px;
height: 257px;
z-index: 99999;
padding: 10px;
margin: 0 auto;
position: relative;
}
#frame {
background: url(../img/slider_frame.png) no-repeat;
width: 964px;
height: 257px;
position: absolute;
top: -3px;
left: -80px;
z-index: 0;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
pointer-events: none;
-moz-box-shadow:;
-webkit-box-shadow:;
box-shadow: 0 0 5px #000, 0 0 6px #000;
}
/*
Slideshow
*/
#slides {
position: absolute;
top: 1px;
left: -74px;
z-index: 100;
width: 954px;
height: 247px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
/*
Slides container
Important:
Set the width of your slides container
Set to display none, prevents content flash
*/
.slides_container {
width: 954px;
position: relative;
display: none;
}
/*
Each slide
Important:
Set the width of your slides
If height not specified height will be set by the slide content
Set to display block
*/
.slides_container a {
width: 570px;
height: 270px;
display: block;
}
.slides_container a img {
display: block;
}
/*
Next/prev buttons
*/
#slides .next, #slides .prev {
position: absolute;
top: 129px;
left: -80px;
width: 48px;
height: 48px;
display: block;
z-index: 101;
}
#slides .next {
background-image: url(../img/arrow-right.png);
}
#slides .next:hover {
background-image: url(../img/arrow-right-hov.png);
}
#slides .prev {
background-image: url(../img/arrow-left.png);
}
#slides .prev:hover {
background-image: url(../img/arrow-left-hov.png);
}
#slides .next {
left: 826px;
}
So essentially, my question is how do I make the images in the slider display inside of the slide's border?
#container {
height: 257px;
width: 964px;
z-index: 99999;
}
#frame {
background: url(../img/slider_frame.png) no-repeat scroll 0 0 transparent;
border-radius: 4px 4px 4px 4px;
box-shadow: 0 0 5px #000000, 0 0 6px #000000;
height: 257px;
left: 0;
pointer-events: none;
position: absolute;
top: -5px;
width: 964px;
z-index: 99999;
}
#slider ul, #slider li {
list-style: none outside none;
margin: 0;
padding: 0;
}
#slider li, #slider2 li {
border-radius: 3px 3px 3px 3px;
height: 247px;
overflow: hidden;
width: 954px;
}
I see above code is use in the demo site