css image with border-radius - html

I am trying to replicate this style, which has a background image, on the other hand I have a div over it that has a right border-radius, I can't do it, I provided the following options adapting them, but I couldn't
enter image description here
Transparent hollow or cut out circle
div{
position:relative;
width:500px; height:200px;
margin:0 auto;
overflow:hidden;
}
div:after{
content:'';
position:absolute;
left:175px; top:25px;
border-radius:100%;
width:150px; height:150px;
box-shadow: 0px 0px 0px 2000px #E3DFD2;
}
body{background: url('https://farm9.staticflickr.com/8760/17195790401_ceeeafcddb_o.jpg';
Background with radius-top inside
div {
background:lightgreen;
width:100%;
height:200px;
position:relative;
text-align:center;
padding:100px 0 0 0;
box-sizing:border-box;
}
div:before {
content:'';
position:absolute;
background:white;
width:100%;
height:100px;
top:0;
left:0;
border-radius:40%;
transform:translatey(-50%);
}

The cut out example with the circle suits fine, You just need to play around with the values in the DevTools/Inspector.
Adjust heights/widths of the :before to stretch the curve to your liking or even mess with % of border radius, then the border width for how much space around it, the top and left to position it to the edges, then use the parent container to trim off right and bottom areas.
.banner {
background: url(https://farm9.staticflickr.com/8760/17195790401_ceeeafcddb_o.jpg);
background-size: cover;
}
.shape {
position: relative;
width: 170px;
height: 440px;
overflow: hidden;
}
.shape:after {
content: '';
position: absolute;
left: -100px;
top: -200px;
border-radius: 100%;
width: 151px;
height: 440px;
border: 200px solid #ffffff;
}
<div class="banner">
<div class="shape">
</div>
</div>

you can do this by clip-path property ..
Note : minimum width required otherwise shape will not display
*{
box-sizing: border-box;
margin: 0;
padding: 0;
}
.container {
width: 100%;
margin: 0 auto;
display: flex;
}
.left{
width: 10%;
}
.image {
width: 90%;
height: 400px;
overflow: hidden;
background: url(https://farm9.staticflickr.com/8760/17195790401_ceeeafcddb_o.jpg);
background-size: cover;
clip-path: circle(100% at 100% 50%);
}
<div class="container">
<div class="left">
</div>
<div class="image">
</div>
</div>

Related

Creating a circular border radius on multiple child components

so what i am trying to do is have a circle which inside of it, contains an image and a description which overlays the image at 50% Opacity. Heres the result so far:
So, obviously, i want the entire div to have this border-radius, and so far have had to set the parent and img components to have this certain border-radius. What i was wondering was how to have all elements with a circular radius,
(bonus points possibly using border-radius: XX% and not border-radius: XXpx;). Heres what i have tried so far:
JSX
return(
<div className="container">
<img src={this.props.src} alt=""/>
<div className="descriptor">
<h4>{this.props.title}</h4>
</div>
</div>
);
CSS
.container{
margin: 20px;
height: 200px;
width: 200px;
border-radius: 20px;
position: relative;
border-radius: 100px;
display: inline-block;
border-radius:100px;
border:2px solid red;
}
.container img{
max-width:100%;
border-radius:100px;
float: left;
}
.descriptor{
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 30%;
background-color: black;
display: flex;
flex-direction: column;
justify-content: center;
color: white;
opacity: 0.5;
/*NOTE: Here i have tried using things like border-bottom-left-radius: 750px;
But yeah that didnt work*/
}
Here's a demonstration with the comments for the appropriate CSS style attributes.
.roundc{
width:300px; /*Width and height need to be equal for border radius*/
height:300px; /*50% to work and make the square circular */
display:inline-block;
border-radius: 50%; /*Make the container circular */
border:3px solid red;
overflow: hidden; /*Hide the content overflow */
position:relative; /*To use absolute positioning on img*/
}
.roundc img{ /*To center the large image */
position:absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
}
.roundc span{
position:absolute;
z-index:1;
background:red;
color:white;
width:300px;
height:30px;
text-align:center;
bottom:0;
}
<div class="roundc">
<img src="http://via.placeholder.com/350x350">
<span> About me </span>
</div>

CSS3 image aspect ratio lightbox

I have a problem creating a CSS3 ONLY lightbox. This is my current code:
div#image-1 {
position: fixed;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
padding: 1%;
text-align: center;
background-color: rgba(0, 0, 0, 0.5);
}
div#image-1 > div {
width: auto;
height: auto;
max-width: 100%;
max-height: 100%;
display: inline-block;
border: 2px solid red;
}
div#image-1 > div > img {
width: auto;
height: auto;
max-width: 100%;
max-height: 100%;
}
<div id="image-1">
<div>
<img src="https://pixabay.com/static/uploads/photo/2013/06/29/06/24/lotus-142028_960_720.jpg" alt="image-1" />
</div>
</div>
What I want is to force the image to be contained in the red div, preserving the aspect ratio so it could be auto-resized by window resizing.
I can do it without the red container like so:
div#image-1 {
position:fixed;
top:0px;
right:0px;
bottom:0px;
left:0px;
padding:1%;
text-align:center;
background-color:rgba(0, 0, 0, 0.5);
}
div#image-1 > img {
width:auto;
height:auto;
max-width:100%;
max-height:100%;
}
<div id="image-1">
<img src="https://pixabay.com/static/uploads/photo/2013/06/29/06/24/lotus-142028_960_720.jpg" alt="image01" />
</div>
But I need to have the red container in order to add other stuff (like prev/next buttons, ...) and I need it to have the same height as the picture.
I don't want to set any width or height in pixel because I want it to be responsive and screen adaptive. I don't want to force upscalling by the browser so if the image is smaller than the window, I want the image to be displayed with it's default size, but if the image is larger, I want it to be contained in the red div.
The easiest way is to use image as a background image with background-position: contain;
div#image-1 {
position: fixed;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
padding: 1%;
text-align: center;
background-color: rgba(0, 0, 0, 0.5);
}
div#image-1 > div {
background: transparent url() center / contain no-repeat;
min-width: 100%;
min-height: 100%;
display: inline-block;
border: 2px solid red;
}
<div id="image-1">
<div style="background-image: url(https://pixabay.com/static/uploads/photo/2013/06/29/06/24/lotus-142028_960_720.jpg);"></div>
</div>
I've think of this possibility but the problem is I want to add previous/next buttons on each side of the image with a fixed width and the height of the image for a result as in the code below (the main reason I need the red container is when the image is smaller than the window)
div#image-1 {
position:fixed;
top:0px;
right:0px;
bottom:0px;
left:0px;
padding:1%;
display:flex;
align-items:center;
justify-content:center;
background-color:rgba(0, 0, 0, 0.5);
}
div#image-1 > img {
width:auto;
height:auto;
max-width:100%;
max-height:100%;
}
div#image-1 > a {
width:75px;
height:100%; /*of the red div*/
display:inline-block;
border:2px solid blue;
}
<div id="image-1">
<img src="https://pixabay.com/static/uploads/photo/2013/06/29/06/24/lotus-142028_960_720.jpg" alt="image01" />
</div>

Circle div balloon

Here is my current css for image circle baloon
.circle-image{
width: 64px;
height: 64px;
border-radius: 50%;
background-size: contain;
background-position: center;
background-image: url("/assets/img/dashboard/img-stdn.png");
display: block;
}
And the div output as below:
How I can border the div and become like this?
Let say the image inside the div :
You could use a pseudo element in order to create your speech bubble triangle, as shown in the demo below.
This works by using a skew on a square, and position it absolutely within a relatively positioned container element.
Alternatively, this could be achieved with a single element if you were able to use the background-image instead of an image tag.
.circ {
height: 100px;
width: 100px;
border-radius: 50%;
bordeR: 5px solid tomato;
position: relative;
}
.circ img {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
border-radius: 50%;
}
.circ:before{
content:"";
position:absolute;
top:10%;
right:0;
height:20px;
width:20px;
background:tomato;
transform:skewX(55deg) skewY(10deg);
}
<div class="circ">
<img src="http://i.stack.imgur.com/lCp2t.png" />
</div>
for more info in generating the triangle, you may find this quite a useful demonstration of how to achieve this triangle.
Background-image
By using a background-image instead, you can make this with only a single element.
.circ {
position: relative;
height: 100px;
width: 100px;
border-radius: 50%;
border: 5px solid tomato;
background:url(http://i.stack.imgur.com/lCp2t.png);
background-size:100% 100%;
}
.circ:before{
content:"";
position:absolute;
top:10%;
right:0;
height:20px;
width:20px;
background:tomato;
transform:skewX(55deg) skewY(10deg);
z-index:-1;
}
<div class="circ"></div>
If you're looking for the arrow, this is what you need to add.
http://jsfiddle.net/c3Love5c/1/
.circle-image{
width: 64px;
height: 64px;
border-radius: 50%;
background-size: cover;
background-position: center;
background-image: url("http://i.stack.imgur.com/lCp2t.png");
display: block;
border:3px solid purple;
position:relative;
}
.circle-image:before{
content:'';
display:block;
border:10px solid transparent;
border-top-color:purple;
position:absolute;
right:-5px;
top:5px;
transform:rotate(15deg);
-moz-transform:rotate(15deg);
-webkit-transform:rotate(15deg);
-ms-transform:rotate(15deg);
-o-transform:rotate(15deg);
}

How to arrange div structure with radius using CSS

I am trying to create HTML page shown in this sample image.
I want to place other component on top of this black and maroon circles. For this I am using tag Structure of div and span. And using span background-image to apply this image as background.
My problem is what will be structure of div and span to arrange black circle on radius of div/span tags containing maroon circle as background.
Till now I have center circle placed. I don't know how to arrange other circles around it
div.table-text {
position: fixed;
top: 20%;
left: 20%
}
span.table-text {
position: inherit;
display: block;
width: 60%;
height: 60%;
background-image: url(../images/table-text.png);
background-position: bottom;
background-repeat: no-repeat;
}
<div class="table-text">
<span class="table-text">
</span>
</div>
Im not sure I understood the question, but I'll try to answer.
You can't use something like cos() to arrange elements on HTML, you will have to use negatives margin-top: or position: absolute;
My advise: use negative margins, for the black dots on the left and right.
Edit: I did your job, now pay me! #:
.circle {
display: inline-block;
border-radius: 200px;
position: absolute;
width: 100px;
height: 100px;
background-color: black;
}
#bigCircle {
border-radius: 200px;
width: 400px;
height: 400px;
margin: 0 auto;
background-color: brown;
}
#bottom {
margin: 50px calc(50% - 50px);
}
#left {
margin: -50px calc(25% - 50px);
}
#right {
margin: -50px calc(75% - 50px);
}
<div id="bigCircle"></div>
<div class="circle" id="left"></div>
<div class="circle" id="bottom"></div>
<div class="circle" id="right"></div>
JSFiddle - DEMO
Without knowing the rest of your document structure, I've thrown together this proof of concept for you using absolute positioning which should, hopefully, point you in the right direction.
If you need clarification on anything or any of it doesn't suit your needs, please let me know and I'll attempt to update it accordingly.
*{
box-sizing:border-box;
color:#fff;
font-family:sans-serif;
}
.top{
background:red;
border-radius:50%;
margin:-10% auto 0;
padding:0 0 75%;
position:relative;
width:75%;
}
div>div{
background:green;
border-radius:50%;
overflow:hidden;
padding:0 0 20%;
position:absolute;
width:20%;
}
div.one{
left:-10%;
top:80%;
}
div.two{
left:40%;
top:103%;
}
div.three{
right:-10%;
top:80%;
}
p{
text-align:center;
position:absolute;
margin:0;
width:100%;
}
.top>p{
top:15%
}
.top>div>p{
top:5%;
}
<div class="top">
<p>top</p>
<div class="one">
<p>one</p>
</div>
<div class="two">
<p>two</p>
</div>
<div class="three">
<p>three</p>
</div>
</div>
I think you want like here
for responsive you can use value in percentages or max-width.
<div class="maroon">
<div class="m-child m-child1"></div>
<div class="m-child m-child2"></div>
<div class="m-child m-child3"></div>
<div class="m-child m-child4"></div>
</div>
.maroon{
max-width: 300px;
max-height:300px;
background:maroon;
top:0;
right:0;
bottom:0;
left:0;
margin:auto;
}
.m-child, .maroon{
position: absolute;
border-radius:100%;
}
.m-child{
background: #000;
width:100px;
height:100px;
}
.m-child1{
left: -50px;
top:0;
bottom: 0;
margin: auto;
}
.m-child2{
right: -50px;
top:0;
bottom: 0;
margin: auto;
}
.m-child3{
top: -50px;
left: 0;
right:0;
margin: auto;
}
.m-child4{
bottom: -50px;
left: 0;
right:0;
margin: auto;
}
I think you need something like following: You can make changes as per your requirement.
.middle_circle {
background: none repeat scroll 0 0 red;
border-radius: 100%;
height: 200px;
left: 220px;
position: absolute;
top: 60px;
width: 200px;
}
.circle{
position:relative;
width:5%;padding-bottom:50%;
margin-left:47.5%;
}
.circle div {
position:absolute;
top:0; left:0;
width:100%; height:100%;
-webkit-transform : rotate(24deg);
-ms-transform : rotate(24deg);
transform : rotate(24deg);
}
.circle:before, .circle div:before {
content:'';
position:absolute;
top:0; left:0;
width:100%; padding-bottom:100%;
border-radius: 100%; background:black;
}
<div class="circle">
<div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>
</div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div>
<div class="middle_circle"></div>
Check Fiddle.

Center h1 over image in a div

How to center (vertically,horizontally) properly over an image in a ?
<div class="category-info">
<div class="image">
<h1>Title</h1>
<img src="image.jpg" />
</div>
</div>
CSS
.category-info {
text-align: center;
height: 200px;
width: 770px;
overflow: auto;
margin-bottom: 20px;
}
The image is 770px width and 200px height. I don't what to do next with . I tried several things, without success.
Here you go: http://jsfiddle.net/QjLuP/4/
The CSS:
.image{
position: relative;
background: green; /* IE */
}
.image h1{
z-index: 2;
position: absolute;
top: 50%;
left: 0;
right: 0;
font-size: 20px;
width: 100%;
height: 26px;
padding: 0;
margin: 0;
margin-top: -13px; /* 1/2 height */
text-align: center;
background: red;
background: rgba(170, 0, 0, 0.8); /* CSS3 */
}
.image img{
z-index: 1;
width: 100%;
height: 100%;
position: absolute;
top:0;
right:0;
bottom:0;
left:0;
background:green
}
I threw a position relative on the .image class and set the width and height on the image element (that way it doesn't resize when it loads). I changed the table back to the h1 and added your line-height of 200px. That is the only downside, you'll still have to manually set the line-height of the h1.
HTML:
<div class="category-info">
<div class="image">
<h1>Title</h1>
<img src="http://placekitten.com/770/200" />
</div>
</div>
CSS:
.category-info {
text-align: center;
margin-bottom: 20px;
}
.image{
position:relative;
}
.image img{
width:770px;
height:200px;
}
.image h1{
position:absolute;
width:100%;
color:white;
line-height:200px;
margin:0;
}
JSFiddle: http://jsfiddle.net/5wGwL/2/
Have you tried this?
h1 { text-align:center; }
html
<h1 style="background-image:url(your php source.img)">Title</h1>
css :
h1 {
height: 200px;
width: 770px;
margin-bottom: 20px;
text-align:center;
vertical-align:middle;
line-height:200px;
background:transparent no-repeat scroll 50% 50%;
}
and nothing else