So I have a header that is shown in the snippet below.
My problem is I only want the shadow around the a tag to show on the part that has expanded out of its container div, to create the impression that the white edge is all one element.
Basically I only want the shadow on the left and on the right to go from the bottom of the a element to the bottom of the div. While also showing on the bottom of the a element.
Screenshot of what I'm after in case my descriptive capabilities are not functioning:
I've tried playing with z-index but haven't been able to get it to work.
My thought with z-index was to push the a behind the div, then pull the img in front of all.
I would prefer a CSS-only solution, as I don't want to have to modify the html, but if I have to I have to.
* {
padding: 0;
margin: 0;
}
div {
height: 50px;
width: 100%;
background: white;
box-shadow: 0px 0px 5px #000000;
}
a {
display: inline-block;
margin-left: 30px;
padding: 10px;
height: 60px;
background: white;
box-shadow: 0px 0px 5px #000000;
}
img {
height: 100%;
}
<div>
<a href="#">
<img src="https://via.placeholder.com/200x100">
</a>
</div>
Here is box-shadow syntax,
box-shadow: offset-x | offset-y | blur-radius | spread-radius | color
Try reducing it's spread-radius and increase it shadow towards y-axis.
* {
padding: 0;
margin: 0;
}
div {
height: 50px;
width: 100%;
background: white;
box-shadow: 0px 0px 5px #000000;
}
a {
display: inline-block;
margin-left: 30px;
padding: 10px;
height: 60px;
background: white;
position: relative;
}
a:before {
content: "";
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
box-shadow: 0px 0px 5px #000000;
z-index: -1;
}
img {
height: 100%;
}
<div>
<a href="#">
<img src="https://via.placeholder.com/200x100">
</a>
</div>
EDIT:-
Using jquery you can compute the css for span dynamically. Check this.
Html modified, added a <span> below anchor tag and added shadow to the span
* {
padding: 0;
margin: 0;
}
div {
height: 50px;
width: 100%;
background: white;
box-shadow: 0px 0px 5px #000000;
}
a {
display: inline-block;
margin-left: 30px;
padding: 10px;
height: 60px;
background: white;
/*box-shadow: 0px 0px 5px #000000;*/
z-index:100;
position:absolute;
}
.shadow {
display: inline-block;
margin-left: 30px;
padding: 10px;
margin-top:50px;
height: 10px;
width:120px;
background: white;
box-shadow: 0px 0px 5px #000000;
z-index:0;
position:absolute;
}
img {
height: 100%;
}
<div>
<a href="#">
<img src="https://via.placeholder.com/200x100">
</a>
<span class="shadow">r
</span>
</div>
You can get it by css pseudo element.
Just add css part
a:after {
content:'';
position:absolute;
bottom:0px;
left:0px;
height:20px;
display:block;
width:100%;
box-shadow:5px 5px 5px -5px #000000;
}
a:before {
content:'';
position:absolute;
bottom:0px;
left:0px;
height:20px;
display:block;
width:100%;
box-shadow:-5px 5px 5px -5px #000000;
}
* {
padding: 0;
margin: 0;
box-sizing:border-box;
}
div {
height: 50px;
width: 100%;
background: white;
box-shadow: 0px 0px 5px #000000;
}
a {
display: inline-block;
margin-left: 30px;
padding: 10px;
height: 60px;
background: white;
position:relative;
/* box-shadow:0px 5px 5px -5px #000000; */
}
a:after {
content:'';
position:absolute;
bottom:0px;
left:0px;
height:20px;
display:block;
width:100%;
box-shadow:5px 5px 5px -5px #000000;
}
a:before {
content:'';
position:absolute;
bottom:0px;
left:0px;
height:20px;
display:block;
width:100%;
box-shadow:-5px 5px 5px -5px #000000;
}
img {
height: 100%;
}
<div>
<a href="#">
<img src="https://via.placeholder.com/200x100">
</a>
</div>
Related
What i'm trying to achieve is to create a purely-CSS ribbon which will:
adapt to the included text (working),
floated to the left of container (working),
have a skewed bottom right corner like on below img:
This is my code - HTML:
<div class="container">
<div class="ribbon left_ribbon"><h2>Testing</h2></div>
</div>
and CSS:
.container {
width:80%;
background:grey;
display:block;
min-height:500px;
margin:0 auto;
}
.ribbon{
color: #fff;
margin: 30px 0 50px;
position: relative;
text-transform: uppercase;
background: rgb(0, 164, 239);
box-shadow: 0px 1px 3px rgba(0,0,0,.2);
padding: 10px 15px;
clear: both;
}
div.left_ribbon{
color: #000;
margin-left: -10px;
float: left;
}
div.left_ribbon h2{
margin: 0 12px;
color:#fff;
}
div.left_ribbon::before{
display: block;
width: 10px;
height: 0px;
position: absolute;
bottom: -10px;
left: -10px;
content: "";
border-bottom: 10px solid transparent;
border-right: 10px solid rgb(0, 80, 116);
}
is it doable via CSS or I have to use SVG file?
clip-path can do it easily:
.box {
width:200px;
height:100px;
margin:50px;
position:relative;
background:grey;
}
.box:before {
content:"Ribbon";
font-size:25px;
padding:5px 25px 10px;
position:absolute;
top:10px;
left:-5px;
background:
linear-gradient(#000 0 0) bottom/100% 5px no-repeat
#00a4ef;
clip-path:polygon(0 0,100% 0,80% calc(100% - 5px),5px calc(100% - 5px),5px 100%,0 calc(100% - 5px))
}
<div class="box">
</div>
With some CSS variables to easily control:
.box {
--s:10px; /* skewed part */
--o:5px; /* offset part */
--c:#00a4ef; /* color */
width:200px;
height:100px;
display:inline-block;
margin:5px;
position:relative;
background:grey;
}
.box:before {
content:attr(data-text);
font-size:25px;
padding:5px calc(10px + var(--s)) calc(5px + var(--o)) calc(10px + var(--o));
position:absolute;
top:10px;
left:calc(-1*var(--o));
background:
linear-gradient(#000 0 0) bottom/100% var(--o) no-repeat
var(--c);
clip-path:polygon(0 0,100% 0,calc(100% - var(--s)) calc(100% - var(--o)),var(--o) calc(100% - var(--o)),var(--o) 100%,0 calc(100% - var(--o)))
}
<div class="box" data-text="test"></div>
<div class="box" data-text="another test" style="--c:red;--o:10px;--s:25px"></div>
<div class="box" data-text="another one" style="--c:yellow;--o:0px;--s:40px"></div>
Please modify your CSS as below. pseudo after CSS added making it skewed form bottom right corner and, modified box-shadow from .ribbon for removing visible shadow of skewed area.
.container {
width:80%;
background:grey;
display:block;
min-height:500px;
margin:0 auto;
}
.ribbon{
color: #fff;
margin: 30px 0 50px;
position: relative;
text-transform: uppercase;
background: rgb(0, 164, 239);
box-shadow: 0px 1px 3px rgb(0 0 0 / 0%);
padding: 10px 15px;
clear: both;
}
div.left_ribbon{
color: #000;
margin-left: -10px;
float: left;
}
div.left_ribbon h2{
margin: 0 12px;
color:#fff;
}
div.left_ribbon::before{
display: block;
width: 10px;
height: 0px;
position: absolute;
bottom: -10px;
left: -10px;
content: "";
border-bottom: 10px solid transparent;
border-right: 10px solid rgb(0, 80, 116);
}
div.left_ribbon::after{
content: '';
position: absolute;
top: 0;
right: 0;
border-bottom: 47px solid grey;
border-left: 23px solid rgb(0, 164, 239);
width: 0;
}
<div class="container">
<div class="ribbon left_ribbon"><h2>Testing</h2></div>
</div>
I have this application in R.
How add tooltip when I hover over the icon? Like this:
The icon class is .fa-question-circle. I tried:
HTML:
Text
CSS:
.fa-question-circle
{
position:relative;
}
.fa-question-circle:after
{
background-color:rgba(0, 0, 0, .6);
color: white;
box-sizing:border-box;
content: attr(data-tooltip);
display:none;
padding:5px;
position:absolute;
right: -105px;
bottom: -55px;
z-index:3;
box-shadow: 0 0 3px #000;
border-radius: 0px 10px 10px 10px;
}
.fa-question-circle:hover:after {
display:block;
}
But doesn't work. Thanks.
I found the wrong part. you need use class="fa-question-circle" not class=".fa-question-circle"
.fa-question-circle
{
position:relative;
}
.fa-question-circle:after
{
background-color:rgba(0, 0, 0, .6);
color: white;
box-sizing:border-box;
content: attr(data-tooltip);
display:none;
padding:5px;
position:absolute;
right: -105px;
bottom: -55px;
z-index:3;
box-shadow: 0 0 3px #000;
border-radius: 0px 10px 10px 10px;
}
.fa-question-circle:hover:after {
display:block;
}
Text
You can try something like this and remove . from the class name in your anchor tag.
.fa-question-circle {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.fa-question-circle .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
/* Position the tooltip */
position: absolute;
z-index: 1;
}
.fa-question-circle:hover .tooltiptext {
visibility: visible;
}
<a href="#" class="fa-question-circle">Text
<span class="tooltiptext">My text is a text</span>
</a>
Hello friends I have a problem with mouse hover on a div.
I have created this DEMO from codepen.io
So you can see in this demo when you hover over image the bubble will be shown. But the bubble does not seem out.
Here is the HTML code:
<div class="container"
<div class="present_wrp">
<div class="wo_wrp2 wo-wrp2">
<div class="wo_content2">
<div class="ornekoto"><img src="http://cdn.flaticon.com/png/256/26625.png" width="267" height="250" /><div class="ornot"></div></div>
</div>
</div>
</div>
</div>
and the CSS code:
.container {
margin:0px auto;
width:500px;
height:500px;
margin-top:100px;
}
.wo_wrp *:last-child {
margin-bottom: 0;
}
.wo-wrp2 {
float: left;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
position: relative;
width: 300px;
}
.wo_content2 {
background: none repeat scroll 0 0 #FFFFFF;
background-color: #fff;
padding: 15px;
position: relative;
z-index: 1;
overflow:hidden;
border: 1px solid #97a8bb;
border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius:3px;
}
.wo_content_t2 {
background: none repeat scroll 0 0 #FFFFFF;
background-color: #fff;
padding:5px;
position: relative;
z-index: 1;
overflow:hidden;
border: 1px solid #97a8bb;
border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius:3px;
}
.wo-wrp2:after {
border-radius: 0 0 50% 50% / 0 0 20px 20px;
bottom: 0;
box-shadow: 0 10px 10px rgba(113, 145, 182, 0.5);
content: "";
height: 20px;
left: 10px;
position: absolute;
right: 10px;
}
.ornekoto{
float:left;
width:267px;
height:250px;
background-color:#307cdc;
border-radius:3px;
-webkit-border-radius:3px;
-o-border-radius:3px;
-o-border-radius:3px
}
.ornot
{
position: absolute;
width: 400px;
height: 500px;
padding: 0px;
background: #307cdc;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
display:none;
margin-top:-755px;
}
.ornot:after
{
content: '';
position: absolute;
border-style: solid;
border-width: 15px 15px 0;
border-color: #307cdc transparent;
display: block;
width: 0;
z-index: 1;
bottom: -15px;
left: 58px;
}
.ornekoto:hover .ornot{
display:block;
}
The problem is that you have overflow:hidden; set. If you swap that for a clearfix it will work fine.
Overflow hidden is keeping the height of the container, so you need to first add a clearfix to the div (a clearfix allows the div to keep the height of the floated elements within it).
.cf:before,
.cf:after {
content: " "; /* 1 */
display: table; /* 2 */
}
.cf:after {
clear: both;
}
Next all you need to do is to add this to the surrounding div:
<div class="wo_content2 cf">
And then remove the overflow hidden property
.wo_content2{
overflow:hidden;
}
Demo here:
http://codepen.io/EightArmsHQ/pen/NPbKpz
You're setting overflow: hidden on .wo_content2 which prevents your bubble from popping out of it's parent container (because the "overflow" is hidden). Use a clearfix instead:
.wo_content2 {
background: none repeat scroll 0 0 #FFFFFF;
background-color: #fff;
padding: 15px;
position: relative;
z-index: 1;
/*overflow:hidden;*/ <---------- remove
border: 1px solid #97a8bb;
border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius:3px;
}
.wo_content2:after {
content: '';
display: block;
clear: both;
}
CODEPEN
I have 3 columns that extend to equal height. The only problem now is that if I have 2 columns only they expand their width and take 100% of the main container. So basically I need them to have the same width wether it's 1, 2 or 3 columns.
Any idea on how to achieve this?
Many thanks!
Fiddle Demo
.content > img {
vertical-align:top;
}
#wrapper {
height: 100%;
width: 100%;
margin: 20px auto;
display:table;
overflow: hidden;
border-spacing: 30px;
}
#wrapper > .col {
display: table-cell;
width: 30.3%;
margin: 0 15px 3px;
background-color: #fff;
text-align: center;
position: relative;
height: 100%;
padding-bottom: 2px;
border:1px solid #000;
}
#wrapper > .col > .content {
padding:0 0 35px;
height:100%;
}
.content {
margin-bottom:30px;
position: relative;
}
.content > p {
vertical-align:top;
}
.content h3 {
font-size:1.375rem;
font-weight:400;
text-align:center;
margin-bottom: 20px;
padding: 25px 27px 0;
}
.content p {
text-align:left;
padding: 0 27px 30px;
}
.button.moreinfo {
margin-top: 5px;
margin-bottom: 0;
padding-top: 0.5rem;
padding-right: 0.3rem;
padding-bottom: 0.5rem;
padding-left: 0.3rem;
background-color: #2a2a2a;
font-size: 0.9rem;
color: #f39c12;
font-weight: 400 !important;
}
div.btn-align-bottom {
position:absolute;
bottom:50px;
left:0;
right:0;
}
.info-box {
margin-bottom:0;
margin-top: 15px;
}
.info-box img {
max-width: 100%;
max-height: 100%;
vertical-align: middle;
}
.info-box-inner {
background: #FFF;
padding:25px 27px 35px;
display:inline-block;
overflow:hidden;
float:none;
min-height:270px;
text-align:center;
-moz-box-shadow: 0px 1px 2px rgba(48, 48, 48, 0.3);
-webkit-box-shadow: 0px 1px 2px rgba(48, 48, 48, 0.3);
box-shadow: 0px 1px 2px rgba(48, 48, 48, 0.3);
z-index:1;
}
.info-box-inner p {
text-align:left;
}
.info-box-inner h3 {
font-size:1.375rem;
font-weight:400;
text-align:center;
}
Okay, finally here is my working jsFiddle demo. See http://jsfiddle.net/rfjg4/10/show/ for the result.
I added the class col2 to the second wrapper and the CSS:
.wrapper.col2:after {
content: "";
display: table-cell;
width: 30.3%;
margin: 0 15px 3px;
background-color: #fff;
text-align: center;
height: 100%;
padding-bottom: 2px;
}
With the above code a new cell with empty content is added to the <div class="wrapper col2"> tag.
Alternatively you can avoid the col2 by using CSS 3 selectors:
wrapper:first-child:nth-last-child(3) ~ div::after {
content: "";
display: table-cell;
width: 30.3%;
margin: 0 15px 3px;
background-color: #fff;
text-align: center;
height: 100%;
padding-bottom: 2px;
}
See this jsFiddle or http://jsfiddle.net/rfjg4/11/show/ for an example. (See this Stackoverflow question Can CSS detect the number of children an element has? for explanation of the selectors).
Some notes:
In your jsFiddle example you used two times id="wrapper" for a <div>. You have to change the id to a class (and update your CSS)
There is one </div> extra in line 17 (and in other lines, too). Those tags are marked red in jsFiddle.
You do not need position:relative; in your CSS (I deleted it in the example).
I'm trying to center an anchor tag which is displayed as a CSS3 shape (a large "play"-arrow) in a div.
My markup is as follows:
<div class="element halfcol">
<div class="inner beige-bg fullheight">
<div class="element-content">
</div>
</div>
</div>
And the CSS is:
.element {
float: left;
margin-right: 20px;
margin-bottom: 20px;
}
.element .inner {
border: 2px solid #94111e;
min-height: 50px;
border-radius: 10px;
background-color: #fcf9e3;
height: inherit;
-moz-box-shadow: 2px 2px 6px #646464;
-webkit-box-shadow: 2px 2px 6px #646464;
box-shadow: 2px 2px 6px #646464;
}
.element .inner .element-content {
padding: 10px 15px;
height: inherit;
}
.element .inner .no-padding {
padding: 0px;
}
.element .beige-bg {
background-color: #fcf9e3;
}
.element .red-bg {
background-color: #94111e;
}
.element .transparent-bg {
background-color: transparent;
}
.element .white-bg {
background-color: #ffffff;
}
.element .smallheight,
.element .doubleheight,
.element .fullheight {
overflow-y: hidden;
}
.element .smallheight {
height: 90px;
}
.element .doubleheight {
height: 220px;
}
.element .doubleheight .element-content {
position: relative;
}
.element .fullheight {
height: 350px;
}
.element .no-padding {
padding: 0px !important;
}
/**** Shapes ****/
.play-button {
display: block;
margin: 0 auto;
border-left: 100px solid #94111e;
border-top: 60px solid transparent;
border-bottom: 60px solid transparent;
}
Which gives me this:
What I'm looking for is this:
I could just give it a margin top/left to center it, but the .element container is of variable height and width.
Anyone know how to achieve this? :-)
Thanks in advance!
You need to make the .element-content be position:relative and then
add
position:absolute;
top:50%;
left:50%;
margin-top:-60px;
margin-left:-50px;
to the .play-button
Demo at http://jsfiddle.net/jKs6F/
I changed your .play-button class as follows:
.play-button {
display: block;
margin: 0 auto;
border-left: 100px solid #94111e;
border-top: 60px solid transparent;
border-bottom: 60px solid transparent;
margin-left: -50px; /* half border-left value */
margin-top: -60px; /* border-top value */
position: relative; left: 50%; top: 50%;
}
See demo