I have one image with drop-shadow and I want text at the bottom of the image with overlay class named img_text which takes the same shape as image. I don't know how to create this.
Can anyone help me how to achieve this?
Here I have attached what I want.
Here is my code in pen that I have done.
The issue is, a child element cannot be related to it's parents background, the two shapes are independent of each other.
This is a classical HTML challenge, when table layouts were pulled together with interactive effects, to use more images in more colourful images with Photoshop filters applied to text menu items or gifs.
As Basil suggested an additional image could provide the illusion that the two shapes are related, alternatively the base image could look as required, then only one line of label may be provided.
This CSS may be applied:
backdrop-filter: sepia(.9) hue-rotate(0deg)
Rather than the background on .images_div .img_text
Play around with the hue-rotate to see if you can make the same orange.
The only way to achieve this is by using an image background that have the same shape with less opacity like this one instead of this background-color: rgba(0,0,0,0.5);.
You can try this code
CSS code
* {
box-sizing: border-box;
}
.container {
position: relative;
}
.container p {
position: absolute;
bottom: 0px;
left: 0px;
right: 0px;
overflow: hidden;
background-color: rgba(0,0,0,0.5);
color: #F2F2F2;
font-size: 22px;
text-align: center;
background-color: red;
width: 180px;
display: block;
padding: 10px 15px;
text-align: center;
text-transform: uppercase;
color: #fff;
}
.container .image_sec_img p:hover{
background-color: rgba(248,105,60,0.75);
}
.one{
margin-left: 16px;
}
and the html code
<div class="container">
<div class="image_sec_img">
<img src="https://i.stack.imgur.com/Xcapo.png">
<p class="one">Hello</p>
</div>
</div>
Try to implement this way.
.image_box {
display: inline-block;
clip-path: polygon(0% 100%, 0% 5%, 10% 3%, 20% 1.7%, 35% 0.4%, 50% 0%, 65% 0.4%, 80% 1.7%, 90% 3%, 100% 5%, 100% 93%, 90% 95.7%, 80% 97.7%, 70% 99.2%, 60% 99.9%, 50% 100%, 40% 99.3%, 30% 97.7%, 20% 95.9%, 10% 95.3%, 0% 96%);
padding: 0px 0px 4px 5px;
position: relative;
}
.image_box:before {
background-color: #f8693c;
left: 0px;
top: 20px;
bottom: 0;
right: 5px;
position: absolute;
content: "";
}
.content {
position: absolute;
bottom: 0;
left: 0px;
right: 0px;
background-color: rgba(248, 105, 60, 0.9);
color: #fff;
padding: 15px 15px 30px 25px;
clip-path: polygon(0% 0%, 100% 0%, 100% 93%, 90% 95.7%, 80% 97.7%, 70% 99.2%, 60% 99.9%, 50% 100%, 40% 99.3%, 30% 97.7%, 20% 95.9%, 10% 95.3%, 0% 96%);
}
.image_box img {
display: block;
clip-path: polygon(0% 100%, 0% 5%, 10% 3%, 20% 1.7%, 35% 0.4%, 50% 0%, 65% 0.4%, 80% 1.7%, 90% 3%, 100% 5%, 100% 93%, 90% 95.7%, 80% 97.7%, 70% 99.2%, 60% 99.9%, 50% 100%, 40% 99.3%, 30% 97.7%, 20% 95.9%, 10% 95.3%, 0% 96%);
}
<div class="image_box">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT6lRhSay69skaUU-y9M7J_drwez_QBJTPholjizBmGbfJbLYVH&s">
<div class="content">
Image Title
</div>
</div>
Hope this will works fine for you.
Thank you...
here you go miss Akshita sorry for my side
css
.cont1 {
display: inline-block;
clip-path: polygon(0% 100%, 0% 5%, 10% 3%, 20% 1.7%, 35% 0.4%, 50% 0%, 65% 0.4%, 80% 1.7%, 90% 3%, 100% 5%, 100% 93%, 90% 95.7%, 80% 97.7%, 70% 99.2%, 60% 99.9%, 50% 100%, 40% 99.3%, 30% 97.7%, 20% 95.9%, 10% 95.3%, 0% 96%);
padding: 0px 0px 4px 5px;
position: absolute;
}
.cont1:before {
background-color: #f8693c;
left: 0px;
top: 40px;
bottom: 0;
right: 5px;
position: absolute;
content: "";
}
.text1{
position: absolute;
bottom: 0;
left: 0px;
right: 0px;
background-color: rgba(248, 105, 60, 0.9);
color: #fff;
text-align: center;
padding: 15px 15px 30px 25px;
clip-path: polygon(0% 0%, 100% 0%, 100% 93%, 90% 95.7%, 80% 97.7%, 70% 99.2%, 60% 99.9%, 50% 100%, 40% 99.3%, 30% 97.7%, 20% 95.9%, 10% 95.3%, 0% 96%);
}
.cont1 img {
display: block;
clip-path: polygon(0% 100%, 0% 5%, 10% 3%, 20% 1.7%, 35% 0.4%, 50% 0%, 65% 0.4%, 80% 1.7%, 90% 3%, 100% 5%, 100% 93%, 90% 95.7%, 80% 97.7%, 70% 99.2%, 60% 99.9%, 50% 100%, 40% 99.3%, 30% 97.7%, 20% 95.9%, 10% 95.3%, 0% 96%);
}
html
<div class="cont1">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT6lRhSay69skaUU-y9M7J_drwez_QBJTPholjizBmGbfJbLYVH&s">
<div class="text1">
Hello
</div>
</div>
Related
I want a shadow around and iside the hole of a cut donut polygon .
Hello,
I am trying to do a button in form of a cut donut but I am having trouble putting borders to it without making another polygon inside, so I tried to put shadows but only inset box-shadow was working and that wasn't what I wanted.
Here is the code :
body>
<div class="container">
<div class="polygon"></div>
</div>
</body>
and css :
:root{
--color1 : #86a59c;
--color2 : #284141;
--lightShadow : #ffffff55;
--darkShadow : #0000001E;
--polygon : polygon( 0% 50%, 1.01020514433644% 40%, 4.1742430504416% 30%, 10% 20%, 15% 18%, 20% 20%, 30% 30%, 30.5% 32.5%, 30% 35%, 27.0871215252208% 40%, 25% 50%, 27.0871215252208% 60%, 30% 65%, 35% 70%, 40% 72.9128784747792%, 50% 75%, 60% 72.9128784747792%, 65% 70%, 70% 65%, 72.9128784747792% 60%, 75% 50%, 72.9128784747792% 40%, 70% 35%, 69.5% 32.5%, 70% 30%, 80% 20%, 85% 18%, 90% 20%, 95.8257569495584% 30%, 98.9897948556636% 40%, 100% 50%, 98.9897948556636% 60%, 95.8257569495584% 70%, 90% 80%, 80% 90%, 70% 95.8257569495584%, 60% 98.9897948556636%, 50% 100%, 40% 98.9897948556636%, 30% 95.8257569495584%, 20% 90%, 10% 80%, 4.1742430504416% 70%, 1.01020514433644% 60%);}
body {
padding: 0;
margin: 0;
background-color: #888888;
font-size: 0.3em;
}
.container {
height: 20em;
width: 20em;
background: var(--color1);
position: absolute;
filter: drop-shadow(0px 10px 5px rgba(0,0,0,0.5));
}
.polygon {
content: "";
position: absolute;
margin: auto;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 80%;
width: 80%;
background-color: var(--color2);
clip-path: var(--polygon);
}
What do you think? The main problem is chadow around and inside the hole of the donut.
I'd like to create a scotch tape band design on my website. I would like it to look almost like that :
I designed yet the clean tape but I cannot manage to create the bendings (circled on the picture) properly.
this is what I have yet.
body {
overflow: hidden;
}
.duct-tape {
display: flex;
justify-content: space-around;
align-items: space-around;
transform-origin: center;
position: absolute;
top: 50%;
left: 50%;
width: 100vw;
background-color: yellow;
overflow: hidden;
}
.duct-tape:nth-of-type(1) {
transform: translate(-50%, -50%) rotateZ(-20deg);
}
.duct-tape:nth-of-type(2) {
transform: translate(-50%, -50%) rotateZ(30deg);
}
.duct-tape > .shadow {
display: block;
position: absolute;
height: .3px;
width: 50px;
transform: rotateZ(-30deg) translateX(13px);
border-radius: 100%;
box-shadow: .1em .1em .25em rgb(130, 130, 0);
}
/* debug code */
.circle {
content: "";
display: block;
border-radius: 100px;
width: 30px;
height: 30px;
border: 2px solid lightblue;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-60%, -60%);
}
<body>
<div class="duct-tape">
<span>any text</span>
<span>any text</span>
</div>
<div class="duct-tape">
<span>any text</span>
<span>any text</span>
<span class="shadow"></span>
</div>
<!-- debug code -->
<span class="circle"></span>
</body>
Yet I thought about create little shadow elements (class shadow in duct-tape in the snippet) that would act like the bendings. I thought about svg too, but it doesn't seem I can easily create such an svg. I know css packs up 3D transforms, could it help me or this is too specific to be properly done using css 3D transforms ? Any idea of easier ways to do it ?
You may take a look at clip-path, rgba() colors and gradient.
here is a quick example to show the idea.
body {
background: yellow;
}
span {
--rt: 45deg;
position: absolute;
height: var(--ht, 400px);
width: var(--wdt, 50px);
background: linear-gradient(30deg, transparent 30%, rgba(255, 255, 255, 0.3) 32%, transparent 33%), radial-gradient(circle at 60% 40%, transparent 15px, rgba(255, 255, 255, 0.25) 17%, transparent 20%) rgba(0, 0, 0, 0.075);
box-shadow: 0 0 2px rgba(255, 255, 255, 0.6);
top: 50%;
left: 50%;
margin: -200px -25px;
transform: rotate(var(--rt));
clip-path: polygon(1% 0%, 19% 1%, 30% 0%, 38% 0%, 48% 1%, 58% 3%, 62% 3%, 79% 3%, 73% 1%, 84% 0%, 87% 0%, 91% 4%, 92% 2%, 99% 0%, 96% 5%, 96% 20%, 100% 34%, 100% 46%, 99% 54%, 95% 57%, 87% 69%, 100% 77%, 100% 82%, 100% 89%, 100% 96%, 90% 99%, 76% 100%, 71% 97%, 63% 100%, 54% 99%, 51% 100%, 37% 98%, 34% 100%, 21% 99%, 17% 100%, 14% 98%, 10% 100%, 3% 98%, 3% 100%, 0% 85%, 4% 80%, 0% 74%, 4% 55%, 6% 45%, 3% 40%, 0% 34%, 6% 25%, 4% 16%, 1% 13%);
}
span:nth-child(2) {
--rt: -45deg;
--ht: 450px;
background-size: 150% 200%;
clip-path: polygon(0 0, 13% 2%, 22% 0%, 28% 0%, 34% 2%, 46% 2%, 60% 2%, 69% 3%, 79% 1%, 80% 0%, 90% 0%, 93% 3%, 100% 4%, 99% 98%, 97% 100%, 87% 99%, 80% 100%, 74% 99%, 68% 100%, 60% 99%, 50% 100%, 43% 97%, 33% 96%, 31% 98%, 24% 99%, 20% 100%, 14% 98%, 9% 100%, 0% 100%);
}
span:nth-child(3) {
--rt: -45deg;
--wdt: 40px;
--ht: 200px;
left: 25%;
background-size: 110% 200%;
}
span:nth-child(4) {
--rt:15deg;
--wdt: 40px;
--ht: 150px;
left: 25%;
background-size: 40% 50%;
clip-path: polygon(0 0, 13% 2%, 22% 0%, 28% 0%, 34% 2%, 46% 2%, 60% 2%, 69% 3%, 79% 1%, 80% 0%, 90% 0%, 93% 3%, 100% 4%, 99% 98%, 97% 100%, 87% 99%, 80% 100%, 74% 99%, 68% 100%, 60% 99%, 50% 100%, 43% 97%, 33% 96%, 31% 98%, 24% 99%, 20% 100%, 14% 98%, 9% 100%, 0% 100%);
}
<span></span>
<span></span>
<span></span>
<span></span>
gradient linear,radial and conic can be used via background and resized and repeated or not, clip-path can allow you to cut off some pieces . a usefull tool to help you https://bennettfeely.com/clippy/
mask svg is also a possibility instead clip-path or mixed with.
This question already has answers here:
Setting the width of inline elements
(7 answers)
Closed 2 years ago.
I have recently been learning about the magical properties of clip-path in CSS, but I ran into a problem when trying to create a custom image link. I have been unable to get the actual shape to be a clickable link.
When I try and place an <a> within the clipped div, the shape itself will not be clickable - even if I set it to the same dimensions as it's parent div. This is my reference site for the linkable clip-path ( https://css-tricks.com/the-many-ways-to-link-up-shapes-and-images-with-html-and-css/ ).
I am wondering if it's not able to be a link since it has an animation upon mouse hover? Here is my code snippet.
/* Styles the link */
#inner-link {
width: 200px;
height: 200px;
}
/* Styles the parent container */
#button-container {
width: 200px;
height: 200px;
margin: 10%;
background-color: #ed991c;
clip-path: polygon(50% 0%, 100% 100%, 0% 100%, 0% 100%, 0% 100%, 0% 100%, 0% 100%);
}
#button-container:hover {
animation: arrow 0.5s forwards;
}
/* animation from triangle to arrow */
#keyframes arrow {
0% {
clip-path: polygon(50% 0%, 100% 100%, 0% 100%, 0% 100%, 0% 100%, 0% 100%, 0% 100%);
background-color: #ed991c;
}
100% {
clip-path: polygon(30% 0%, 100% 50%, 30% 100%, 30% 75%, 0% 75%, 0% 25%, 30% 25%);
background-color: #edd11c;
}
}
<div id="button-container">
<a id="inner-link" href="https://www.target.com/"><a>
</div>
a tag is an inline element, and inline elements don't have heights or widths.
A quick fix would be to add display: block or display: inline-block to your #inner-link.
#inner-link {
width: 200px;
height: 200px;
display: block;
}
#inner-link {
width: 200px;
height: 200px;
display: block;
}
/* Styles the parent container */
#button-container {
width: 200px;
height: 200px;
margin: 10%;
background-color: #ed991c;
clip-path: polygon( 50% 0%, 100% 100%, 0% 100%, 0% 100%, 0% 100%, 0% 100%, 0% 100%);
}
#button-container:hover {
animation: arrow 0.5s forwards;
}
/* animation from triangle to arrow */
#keyframes arrow {
0% {
clip-path: polygon( 50% 0%, 100% 100%, 0% 100%, 0% 100%, 0% 100%, 0% 100%, 0% 100%);
background-color: #ed991c;
}
100% {
clip-path: polygon( 30% 0%, 100% 50%, 30% 100%, 30% 75%, 0% 75%, 0% 25%, 30% 25%);
background-color: #edd11c;
}
}
<div id="button-container">
<a id="inner-link" href="https://www.target.com/"></a>
</div>
Following is my code in which I am unable to create a bottom curve but increasing the border-top-left-radius/border-top-right-radius is not able to create a bump as shown in fig. Let me know how can I handle this using CSS only.
Code:
.container {
position: relative;
}
.rect {
width: 334.5px;
height: 223px;
background: #34EFEE;
text-align: center;
line-height: 223px;
}
.rect:after {
content: '';
position: absolute;
bottom: 0px;
width: 334.5px;
height: 15px;
background: #FFFFFF;
left: 0;
border-top-left-radius: 50%;
border-top-right-radius: 50%;
}
<div class="container">
<div class="rect">
<h3>334.5 X 223</h3>
</div>
</div>
Expected Output -
PLNKR -- http://plnkr.co/edit/7oTCHyn8PFABri0KHSrH?p=preview
You can use :after pseudo element to create shape and add large box-shadow for blue background.
div {
width: 300px;
height: 150px;
position: relative;
overflow: hidden;
text-align: center;
color: white;
}
div:after {
content: '';
box-sizing: border-box;
position: absolute;
bottom: 0;
left: 50%;
height: 100px;
width: 120%;
border: 5px solid black;
transform: translate(-50%, 50%);
box-shadow: 0px 0px 0px 200px #00A2E8;
border-radius: 50%;
z-index: -1;
}
<div>Lorem ipsum</div>
Try this code change height and border-top-left-radius like
.container {
position: relative;
}
.rect {
width: 334.5px;
height: 130px;
background: #34EFEE;
text-align: center;
line-height: 223px;
}
.rect:after {
content: '';
position: absolute;
bottom: 0px;
width: 334.5px;
height: 70px;
background: #FFFFFF;
left: 0;
border-top-left-radius: 80%;
border-top-right-radius: 100%;
}
<div class="container">
<div class="rect">
<h3>334.5 X 223</h3>
</div>
</div>
try this code:
.container {
position: relative;
}
.rect {
width: 334.5px;
height: 223px;
background: #34EFEE;
text-align: center;
line-height: 223px;
}
.rect:after {
content: '';
position: absolute;
bottom: 0px;
width: 360px;
height: 360px;
transform: rotate(45deg);
background-color: #fff;
left: -11px;
bottom: -270px;
border-radius: 30px;
}
<div class="container">
<div class="rect">
<h3>334.5 X 223</h3>
</div>
</div>
May as well through in another answer, this is not one I'd expect you to use but is one that uses clip path.
body {
background: #eee;
}
div {
width: 300px;
height: 150px;
position: relative;
overflow: hidden;
text-align: center;
color: white;
background: #00A2E8;
border-radius: 0 0 5px 5px;
-webkit-clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 96% 99%, 92% 97%, 88% 95%, 84% 93%, 80% 91%, 76% 89%, 72% 87%, 68% 85%, 64% 83%, 60% 81%, 56% 79%, 52% 78%, 50% 78%, 48% 78%, 44% 79%, 40% 81%, 36% 83%, 32% 85%, 28% 87%, 24% 89%, 20% 91%, 16% 93%, 12% 95%, 08% 97%, 04% 99%, 0% 100%);
clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 96% 99%, 92% 97%, 88% 95%, 84% 93%, 80% 91%, 76% 89%, 72% 87%, 68% 85%, 64% 83%, 60% 81%, 56% 79%, 52% 78%, 50% 78%, 48% 78%, 44% 79%, 40% 81%, 36% 83%, 32% 85%, 28% 87%, 24% 89%, 20% 91%, 16% 93%, 12% 95%, 08% 97%, 04% 99%, 0% 100%);
}
<div>Lorem ipsum</div>
I'm trying to do something seemingly easy but its not working out for me.
I have a simple button with a shimmer hover effect. I want have the same button effect applied to a button that is shaped like a hexagon. I thought I'd be pragmatic and just overlay the button with a clip-path (I don't care about the browser support). but, sadly the pseudo-element affect the clip-path making it unusable. Am I missing something simple? Or will the combination of these two never work?
.button {
outline:none;
border:none;
padding:20px;
display:block;
margin:0 auto;
cursor:pointer;
font-size:16px;
font-weight: bold;
background-color:#DBBD68;
text-transform: uppercase;
position:relative;
transition:all 0.5s ease;
overflow: hidden;
color:#fff;
&.hex{
width: 280px;
height: 280px;
position:absolute;
top: 0;
left:0;
-webkit-clip-path: polygon(20% 50%, 12% 60%, 20% 70%, 82% 70%, 89% 60%, 80% 50%);
clip-path: polygon(20% 50%, 12% 60%, 20% 70%, 82% 70%, 89% 60%, 80% 50%);
}
&:before {
content: '';
background-color: rgba(255,255,255,.5);
width:100%;
height:20px;
position:absolute;
left:-135px;
transform: rotateZ(45deg)
}
I made a Fiddle to showcase the issue: https://jsfiddle.net/0m5wmvu8/
You tried to do something crazy with .hex, but the only thing you should have added was the clip-path. Just change it to:
&.hex{
-webkit-clip-path: polygon(50% 0, 80% 0, 100% 50%, 80% 100%, 20% 100%, 0 50%, 20% 0);
clip-path: polygon(50% 0, 80% 0, 100% 50%, 80% 100%, 20% 100%, 0 50%, 20% 0);
}
https://jsfiddle.net/8sfc3ott/