How to create shape with a wavy edge - css

I need to make custom shape(see image attached) on Dreamweaver and found the code below for reference. I'm not sure which values to change in the reference code to achieve my custom shapes. I don't know which values to change: top, left, width, or height to suit my custom shape. My max width of the shape is 1832px. Max height of wave is 179px. Lesser wave height is 113px. Please help.
Reference:
http://jsfiddle.net/7fjSc/9/
#wave {
position: relative;
height: 70px;
width: 600px;
background: #e0efe3;
}
#wave:before {
content: "";
display: block;
position: absolute;
border-radius: 100% 50%;
width: 340px;
height: 80px;
background-color: white;
right: -5px;
top: 40px;
}
#wave:after {
content: "";
display: block;
position: absolute;
border-radius: 100% 50%;
width: 300px;
height: 70px;
background-color: #e0efe3;
left: 0;
top: 27px;
}
<div id="wave"></div>

You can see from this link:
http://jsfiddle.net/7fjSc/1248/
#wave:before
and
#wave:after
refer to two elliptical circles that are positioned over a rectangle. The left ellipsis is the same color as the rectangle (#e0efe3) while the ellipsis to the right is the same color as the background (white). This is a common technique with CSS to make rounded objects. Your example places smaller circles over a large rectangle, but to achieve the shape you want, you will have to place larger circles over a smaller rectangle (this will give you the curved shape on the left side). To achieve elliptical circles, change the border-radius attribute. Manipulation of these attributes should allow you to obtain the shape you need. Good luck!

Related

Why there are borders appearing in a element with mix-blend-mode property?

I am trying to fit a div inside a shape using mix-blend-mode:screen. Although on large screen it looks good when I use chrome reponsive tool on some screens are shown borders like this is there a way to remove these borders?
Here is my code
.banner-img {
width: 100%;
max-width: 1000px;
height: 100%;
background-size: 100% 100%;
margin-left: -75px;
display: flex;
align-items: center;
position: relative;
background-color: rgba(51,51,51,0.8);
background-blend-mode: overlay;
&::before{
content: "";
position: absolute;
height: 100%;
top: 0;
left: 0;
width: 100%;
background-image: url('../../../Assets/mask.jpg');
background-size: 100% 100%;
border: none;
mix-blend-mode: screen;
}
<div className={`banner-content ${props.styles}`}>
<div className="banner-img" style={{ backgroundImage: `url(${props.img})` }}>
<div className="content">{<props.content />}</div>
</div>
<div className="content">{props.children}</div>
</div>
https://jsfiddle.net/d5rw3zkg/8/
UPDATE: the original 'fix' in this answer hid the border but altered the shape. #Alfred found that changing the height to calc(100% + 1px) rather than 101% fixed the problem - both hiding the border and keeping the correct shape.
Here's the original answer and the surmise as to the reason:
This is not a full answer to the question as I cannot reproduce the problem on any of the devices I have. But I have seen similar problems before where somehow there isn't an exact overlap of two images. This is possibly because of the mismatch between CSS and actual device pixels (which can be several pixels to make up one CSS pixel) but this is just a surmise.
Could you try this experiment? On a device where you can see the problem, also run it with just one setting changed in the SCSS. This is to see whether we can get the mask to stretch just beyond the underlying image so there is no chance of a sliver being left behind.
&::before{
content: "";
position: absolute;
height: 100%;/**CHANGE TO 101% (original answer) now calc(100% + 1px) **/
top: 0;
left: 0;
width: 100%;
background-image: url('../../../Assets/mask.jpg');
background-size: 100% 100%;
border: none;
mix-blend-mode: screen;
}

Can I achieve underline and circle with css?

I want to achieve the following layout with the help of css. I want to be able to selectively underline text and draw circle around text elements.
This has somewhat of a chalk effect. Any pointers would be useful.
Sample Image
You want to have this freehand drawing effect right?
with css you can only make exact shapes that are not as handmade.
this effect you can do in two ways:
-Use images as background in the case of the circle and as image (<img>) in the case of the underline
-Using canvas, is an extensive and complex subject but it is the best way to solve your problem if you think about good practices
An example of the first way:
<div class="wrapper-text">
<p>text circle</p>
</div>
.wrapper-text {
width: 100px //width and height a little bigger than p tag
height: 80px;
background-image: url('/path-image-circle.png');
background-repeat: no-repeat;
background-size: 100%;
}
you can also place an image tag inside the wrapper with position: absolute and format the width and height instead of using as background
Yor can wrap the wanted word in span and then make this effect using pseudo elements:
HTML:
<p>Some Text with <span class="underline">underline</span> and <span class="circle">circle</span></p>
CSS:
.underline, .circle {
position: relative;
}
.circle::after{
content: '';
display: block;
width: 30px;
height: 30px;
border: 1px solid green;
position: absolute;
border-radius: 50%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.underline::after{
content: '';
display: block;
width: 100%;
height: 2px;
background: green;
position: absolute;
bottom: 0;
left: 0;
}
DEMO:
https://codepen.io/eliortabeka/pen/RdxVNX
NOTE:
You can change the circle type the any freehand drawing image you wish

Background position: put left corner in center

Hope this image explains more, what I want
(The transparent part of the image should indicate it is bigger than the .content Div :-)
Is there an almost save way (preferably just CSS) to let a background image start at the center?
background-position: center top;
… would use the image's center, not the left corner.
I can't manipulate the image itself (using a transparent offset) nor use absolute values.
You won't be able to do this with a background image on the desired element without using absolute values. See this answer for an illustration of why. In a nutshell, background positioning with percentages and keyword values works much like a sliding puzzle, keeping the image strictly within the element's background positioning area. Only absolute values are exempt from this behavior.
You could cheat by making the image a background of a pseudo-element of the desired element instead, but this requires the desired element to be relatively positioned and act as a containing block for all absolutely positioned descendants, including the pseudo-element:
.content {
position: relative;
height: 200px;
border: 1px solid;
}
.content#one { width: 100px; }
.content#two { width: 200px; }
.content::before {
content: '';
position: absolute;
left: 50%;
width: 50%;
height: 100%;
background: url(http://placehold.it/150x150) no-repeat;
}
<div class="content" id="one"></div>
<div class="content" id="two"></div>
Can be done with pseudo elements
.cimg {
border: 1px solid black;
height: 400px;
position: relative;
}
.cimg::after {
content: "";
position: absolute;
left: 50%;
top: 0;
height: 100%;
width: 50%;
background-image: url("http://www.youramazingplaces.com/wp-content/uploads/2014/06/sunset-5.jpg");
background-repeat: no-repeat;
background-size: 400px;
}
<div class="cimg">
</div>

How can I clip and transform an image, adding rounded corners and perspective?

How can I use HTML and CSS to make a div with an image inside it that is clipped and masked so that it looks like the following:
I've been trying to find a way to do this for about 2 hours now and got nowhere so I was just hoping someone could point me in the right direction. To be specific here, I wish to clip the image such that the top two corners are rounded, and embed it in a div element with four rounded corners and a 1/4 bottom padding, with both elements transformed such that it appears the right edge is further away from the viewer than the left.
In order to create such an effect, where the image remains the same, but the outer shape has this perspective look, you could use something similar to the demo below.
div.inner {/*gives top section effect, also crops the image*/
position: absolute;
top: 0;
left: 0;
border-radius: 20px 20px 0 0;
height: 200px;
width: 300px;
overflow: hidden;
border: 10px solid red;
transform: skewY(5deg);
}
.inner img {/*removes transform skew from image*/
transform: skewY(-5deg);
transform-origin: top left;
height:100%;width:100%;
}
.wrap {
display: inline-block;
height: 200px;
width: 300px;
position: relative;
/*for demo only*/
margin: 100px 100px;
}
.wrap:after { /*give bottom section the effect*/
content: "";
position: absolute;
bottom: -50%;
left: 0;
height: 100%;
width: calc(100% + 20px);
transform: skewY(-10deg);
transform-origin: bottom right;
background: red;
z-index: -1;
border-radius: 20px;
}
<div class="wrap">
<div class="inner">
<img src="http://lorempixel.com/500/500" />
</div>
</div>
In order to create the effect, I have had to incorporate this wrapper div. This allows the use of a pseudo element (the :after css) to generate the lower part of the shape:
+----------------------------+
| |
| _______/ <-- curved corner
| ------/
| ------/
\-----/
/\
\_____ also curved corner
The inner div is then hence used to generate the upper part of the shape. Using the skew declaration, the shape allows the opposite of the :after element, bringing the right hand side of the red shape down wards.
The overflow:hidden ensures any part of the image that does not fit within this inner div will be cropped (the border-radius:20px 20px 0 0; ensures only the upper corners are affected).
The last point to note is the .inner img css. Since I have skewed the .inner div, it is important to then 'unskew' the image so it remains the rectangular shape. This is why there is a 'counter-skew' here (transform: skewY(-5deg);).
Here's my attempt using perspective.
Thanks to #vals for the pointing out that perspective can be used as part of the transform.
* {
box-sizing: border-box;
}
figure {
perspective: 1000px;
width: 420px;
margin: 5em auto;
height: 350px;
background: red;
text-align: center;
padding: 10px;
border-radius: 25px;
transform: perspective(1200px) rotateY(50deg);
}
img {
border-radius: 20px 20px 0 0;
}
<figure>
<img src="http://lorempixel.com/400/200/sports/1/" alt="" />
</figure>

Create A responsive Pear Shape using CSS or responsive Images

For a project I have to create a pear-shaped container. I tried doing this using CSS3 rounded corners but it just doesnt look exactly like it. I then used an image at the bottom, but I need this to be responsive (scalable image).
I want to code something like:
http://tinypic.com/view.php?pic=98fxid&s=5
But as you minimize the browser screen, the layout breaks and the pear shape is not scalable. I would like to know if there is a way to do this using CSS3 OR a better way to do this using scalable images.
By the way, I'm using bootstrap and this is my first attempt at making a website using bootstrap, so any guidance would be much appreciated.
You could create the pear shape using two intersecting circle segments, one for left-hand side and one for the right-hand side. Circle segments are created by limiting the circle to its parent container via overflow: hidden;. To simplify the markup, you can create the child circle elements using the :before and/or :after pseudo elements.
HTML:
<div class="content-form">
<div class="pear-shape left"></div>
<div class="pear-shape right"></div>
</div>
CSS:
.content-form {
width: 75%;
max-width: 325px;
height: 200px;
background: url(http://www.domainandseo.com/bootstrap/img/design.png);
position: relative;
}
.pear-shape {
overflow: hidden;
width: 50%;
height: 200px;
position: relative;
top: 100%;
}
.left { float: left; }
.right { float: right; }
.pear-shape.left:before {
position: absolute;
left: 0;
top: 0;
content: '';
width: 200%;
height: 100%;
border-radius: 0 0 0 250px;
background: url(http://www.domainandseo.com/bootstrap/img/design.png);
}
.pear-shape.right:before {
position: absolute;
top: 0;
right: 0;
content: '';
width: 200%;
height: 100%;
border-radius: 0 0 250px 0;
background: url(http://www.domainandseo.com/bootstrap/img/design.png);
}
Check out this example Fiddle.
At some point, you will be able to use the css shapes module, and there might be some browsers that already support it. In the mean time, you might want to look at SVG or canvas as an option.

Resources