How to mask semi circles inside a rectangle and mask through css? - html

I have a background image and a rectangle made in css above it. What i need is, two semi circles should mask through this rectangle and background image should be seen through this rectangle as shown in the image.

You can do it like this
HTML:
<div id="wrapper">
<div id="rect"></div>
<div id="a">
</div>
<div id="b">
</div>
</div>
CSS:
#wrapper{
position:relative;
width:312px;
height:313px;
background:url(http://i.stack.imgur.com/pZVTb.png);
background-attachment: fixed;
}
#a{
position:absolute;
right:0;
height:120px;
top:100px;
border-top-left-radius:60px;
border-bottom-left-radius:60px;
width:60px;
background:url(http://i.stack.imgur.com/pZVTb.png);
background-attachment: fixed;}
#b{
position:absolute;
left:0;
height:120px;
top:100px;
border-top-right-radius:60px;
border-bottom-right-radius:60px;
width:60px;
background:url(http://i.stack.imgur.com/pZVTb.png);
background-attachment: fixed;
}
#rect{
width:100%;
height:56%;
position:absolute;
top:65px;
background:rgba(120,0,23,.8);
}
FIDDLE
Output:
Change the color and image as you want.!!!!
Also check this : https://stackoverflow.com/a/17751125/1542290

You can do this by controlling the opacity of the rectangle.
Something like this : (0% opacity = 100% transparent) and 1 (100 opacity = 0% transparent)

The following is the css code
.bckgrnd{
background:url('image.jpg');
width:1000px;
height:500px;
}
.rect{
position:relative;
width:700px;
height:200px;
background:pink;
opacity:0.5;
top:100px;
left:150px;
}
.semi{
height:100px;
width:50px;
background:url(image.jpg);
background-attachment:fixed;
position:absolute;
top:40px;
}
.right{
left:0;
border-radius :0 50px 50px 0;
}
.left{
right:0;
border-radius :50px 0 0 50px;
}
and the html mark up as follows
<div class="bckgrnd">
<div class="rect">
<div class="semi right"></div>
<div class="semi left"></div>
</div>
</div>

Related

How Do I Blur The Black Box / Border In This Super Simple Example?

All I am trying to do is replace the black box with a box that will blur the background image. This is an over simplified version of my webpage. If I can just get this code corrected, I can figure out the rest.
Here's my example and code:
https://jsfiddle.net/no_u_turn/8ymc7xeb/1/
body {
background-image:url('https://i.ibb.co/DKtSK1h/background-image.jpg');
background-attachment:fixed;
background-repeat:no-repeat;
background-size:cover;
}
.top-box {
width:100%;
height:600px;
text-align:center;
padding-top:100px;
}
.blur-background-box {
width:300px;
height:300px;
background-color:black;
/*filter:blur(5px);*/
margin:0 auto;
padding-top:50px;
}
.solid-white-box {
width:200px;
height:200px;
background-color:white;
margin:0 auto;
}
.bottom-box {
width:100%;
height:1000px;
background-color:white;
}
<div class="top-box">
<div class="blur-background-box">
<div class="solid-white-box">
</div>
</div>
</div>
<div class="bottom-box">
</div>
Oh yeah, I need this done in CSS only, no JavaScript. Basically, I need the code to work with all browsers and across all devices.
I'll be working on this all night. Any and all suggestions are welcome! Thx in advance.
since you are using background-attachment:fixed; you can then apply the same background on the black box and you will have the needed effect. To avoid having the content blurred use a pseudo element:
body {
background-image:url('https://i.ibb.co/DKtSK1h/background-image.jpg');
background-attachment:fixed;
background-repeat:no-repeat;
background-size:cover;
}
.top-box {
width:100%;
height:600px;
text-align:center;
padding-top:100px;
}
.blur-background-box {
width:300px;
height:300px;
margin:0 auto;
padding-top:50px;
position:relative;
z-index:0;
}
.blur-background-box:before {
content:"";
position:absolute;
z-index:0;
top:0;
left:0;
bottom:0;
right:0;
background-image:url('https://i.ibb.co/DKtSK1h/background-image.jpg');
background-attachment:fixed;
background-repeat:no-repeat;
background-size:cover;
filter:blur(5px);
}
.solid-white-box {
width:200px;
height:200px;
background-color:white;
margin:0 auto;
position:relative;
z-index:1;
}
.bottom-box {
width:100%;
height:1000px;
background-color:white;
}
<div class="top-box">
<div class="blur-background-box">
<div class="solid-white-box">
</div>
</div>
</div>
<div class="bottom-box">
</div>

Divs on top of each other, bottom div edge showing.

I made this sorta simple circular loader-thingy, whith two half circles covered with another two half circles that are positioned right on top of them. The covers rotate and reveal the bottom circles to make it look like a circular loading bar.
The problem is that the edge of the bottom circles are visible in some browsers, and there are some mobile browser issues with that as well. Is there a solution for this?
CSS
.wrap{
position:relative;
width:100px;
height:100px;
overflow:hidden;
border-radius:50px;
}
.circle{
position:absolute;
top:0;
width:50px;
height:100px;
background:black;
}
.cover{
position:absolute;
left:0;
width:50px;
height:100px;
background:white;
}
.halfcircleleft{
width:50px;
position:absolute;
top:0;
left:0;
}
.halfcircleleft .circle{
z-index:3;
border-radius:50px 0 0 50px;
}
.halfcircleleft .cover{
z-index:4;
border-radius:50px 0 0 50px;
}
HTML
<div class="wrap">
<div class="halfcircleleft">
<div class="circle"></div>
<div class="cover"></div>
</div>
<div class="halfcircleright">
<div class="circle"></div>
<div class="cover"></div>
</div>
</div>
what about using a circle with transparent background and white border bigger than holeto put it over the border you want to remove?like:
.hole, .hole2{
z-index:99;
position:absolute;
width:86px;
height:86px;
top:7px;
left:7px;
background:lightgrey;
border-radius:50%;
text-align:center;
line-height:86px;
font-family:Arial;
font-size:38px;
padding-right:2px;
}
.hole2 {
background:transparent;
border:4px solid white;
width:106px;
height:106px;
top:-3px;
left:-3px;
}
then just remove the overflow:hiddenof wrapwhich it's not doing anything (at least in your example)
JSFIDDLE

Image changing div position

I am trying to make two columns separated by or inside a circle page the second column should have an image it like this :
<div class="step second">
<div id="upload-img"></div>
<div id="sperator">
<div class="circle" id="or"><p class="number" style="padding-left:25%;">or</div>
</div>
<div id="default-img">
<img src=""/>
</div>
</div>
But for some reason the position of the #sperator div is changing with the image my css is bit long so here is a js fiddle for more explaining : here
As you can see the image should be in the same line with the other div but its changing the position of the separator div
You should re-check your html tags. Make sure each tag closed correctly
Here your css :
.step{
position:relative;
width:500px;
height:250px;
border:1px solid black;
}
#upload-img{
position:absolute;
left:0;
top:0;
width:50%;
height:100%
}
#default-img{
position:absolute;
right:0;
top:0;
width:50%;
height:100%
}
#upload-img img, #default-img img{
max-width:100%;
max-height:100%;
}
#sperator .circle{
position:absolute;
height:66px;
width:66px;
background-color:black;
top:50%;
left:50%;
margin:-33px auto auto -33px;
border-radius:50%;
z-index:100;
text-align:center;
}
#sperator .circle p{
font-size:35px;
font-family:futura-book;
color:white;
padding:0 !important;
margin:0;
line-height:60px;
}
.step::after{
content:'';
height:100%;
width:3px;
left:50%;
margin-left:-2px;
z-index:90;
position:absolute;
background-color:black;
}
potition:relative will be an area that will "lock" every potition:absolute inside it.
You can use position:relative as parent div and position:absolute as child div.

Several nested DIVs with rounded corners

Hello I am trying to vertical and horizontally align 4 divs inside each other with CSS but nothing is working for me.
Please help me! Thanks in advance
My CSS Please note this is just 1 method ive tried I have been sitting here for about 2 hours messing with this and couldnt figure it out.
* {
margin:0px;
padding:0px;
}
body {
background-color:#454545;
}
.wrapper {
margin:auto;
width:960px;
}
.circle-wrapper {
height:918px;
width:918px;
background-image:url(images/overlay.png);
background-size:cover;
background-position:center center;
background-repeat:no-repeat;
position:absolute;
text-align:center;
margin:auto;
}
.outer-inner-background {
background-image:url(images/center-circle.GIF);
background-size:cover;
background-position:center center;
background-repeat:no-repeat;
position:relative;
height:494px;
width:494px;
margin:auto;
}
.outer-inner-rings {
background-image:url(images/inner-outer-rings.PNG);
background-size:cover;
background-position:center center;
position:relative;
width:494px;
height:494px;
margin:auto;
}
.inner-image {
position:relative;
height:308px;
width:308px;
margin:auto;
}
My HTML: I don't care if the structure changes it just needs to work
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Untitled Document</title>
</head>
<body>
<div class="wrapper">
<div class="circle-wrapper">
<div class="outer-inner-background">
</div>
<div class="outer-inner-rings">
</div>
<div class="inner-image">
<img class="inner-img" src="images/inside-image.PNG" width="308px" height="308px">
</div>
</div>
</div>
</body>
</html>
here my try http://dabblet.com/gist/4013306
code:
css
div {overflow:hidden}
#first {
background:red;
width:400px;
height:400px;
border-radius:300px;}
#second {
background:grey;
height:95%;
width:95%;
border-radius:300px;
margin:2.5%}
#third {
background:green;
height:70%;
width:70%;
border-radius:200px;
margin:15%;}
#forth {
background:black;
height:95%;
width:95%;
border-radius:200px;
margin:2.5%;}
html
<div id="first">
<div id="second">
<div id="third">
<div id="forth"></div>
</div>
</div>
</div>
Try using position: relative; on the container, and position: absolute; on the circles with suitable left and top values to place them in the middle.
Well, you can use absolute positioning in your inner divs where left and top positions are always set to (Parent element width - child element width /2). Here's my code
html
<div id="red">
<div id="grey">
<div id="green">
<div id="black">
</div>
</div>
</div>
</div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
CSS
div
{
border-radius:100%;
}
#red
{
position:relative;
margin-left:auto;
margin-right:auto; /** centers #red on screen **/
background-color: #F00;
width:400px;
​ height:400px;
}
#grey
{
background-color:#CCC;
position:absolute;
top:20px;
left:20px;
width:360px; /** 400 - 360 = 40/2 = 20px for left and top **/
height:360px;
}
#green
{
background-color:#0E0;
position:absolute;
top:40px;
left:40px;
width:280px;
height:280px;
}
#black
{
background-color:#000;
position:absolute;
left:20px;
top:20px;
width:240px;
height:240px;
}​
Here's the fiddle:
http://jsfiddle.net/brunovieira/pmN4z/
Fiddle with #red centered on screen:
http://jsfiddle.net/brunovieira/pmN4z/2/
Does it need to be 4 divs? try this:
http://jsfiddle.net/vSyWZ/2/
HTML
<div class="outer">
<div class="inner"><div>
</div>
​
CSS
div{position:relative; margin:0 auto;}
.outer{width: 350px; height: 350px; background-color: gray; border-radius: 100%; border:10px solid red; vertical-align: middle;}
.inner{width: 200px; height: 200px; background-color: black; border-radius: 100%; border:10px solid green; top:60px;}​
I tested on Chrome and Firefox and works fine, IE doesn't have support for rounded corners but it is centered.

how to use images at the border of div tag all around to give custom border look?

i have set the following css to ger border image of the div container but the problem is that my right image is not coming right on the border but it leaves spaces from the right border side of the div container when it stretches out.
<div id="container">
<div id="left-image"></div>
<div id="main-containts">
<div id="data-containts">
data
</div>
</div>
<div id="right-image"></div>
<div id="bottom">
<div id="bottom-left"></div>
<div id="bottom-center"></div>
<div id="bottom-right"></div>
</div>
</div>
div#container{
position:relative;
margin-left:120px;
margin-right:120px;
float:top;
padding-top:0;
margin-bottom:50px;
width:auto;
height:100%;
}
div#left-image{
position:absolute;
left:0;
width:28px;
height:100%;
float:left;
background:url(border-left.png) repeat-y;
}
div#right-image{
position:absolute;
right:0;
float:right;
width:30px;
height:100%;
margin-right:0;
background:url(border-right.png) repeat-y;
}
div#bottom{
position:absolute;
bottom:0;
width:100%;
height:36px;
z-index:100;
}
div#bottom-left{
width:51px;
height:36px;
background:url(corner-left.png) no-repeat;
float:left;
}
div#bottom-center{
height:36px;
background:url(bottom-image.png) repeat-x;
margin-right:49px;
/*clear:both:*/
}
div#bottom-right{
width:49px;
height:36px;
background:url(corner-right.png) no-repeat;
float:right;
margin-top:-36px;
}
If you are targeting the modern browsers only which supports css3. It could be easily accomplished by the css3 border-image property. Its worth to have a look at the property incase if you are not aware.
http://css-tricks.com/understanding-border-image/
Incase if you want your above code to work.Paste your div structure.