So I have this code:
/*--- Circular images --- */
.img-circular1, .img-circular2, .img-circular3{
width: 200px;
height: 200px;
background-size: cover;
display: block;
border-radius: 100px;
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
float: left;
background: red;
}
.img-circular1{
background-image: url('/Images/learn.jpg');
}
.img-circular2{
background-image: url('/Images/watch.jpg');
}
.img-circular3{
background-image: url('/Images/practice.jpg');
}
#container1
{
top: 100px;
position: relative;
margin-left:auto;
margin-right:auto;
width:70%;
background-color: green;
overflow: auto;
bottom: 0;
}
<div id="container1" style="padding-bottom: 500px;">
<div class="img-circular1"></div>
<div class="img-circular2"></div>
<div class="img-circular3"></div>
<div class="img-circular1"></div>
</div>
I have no managed to get 2 of them to show in a green box. But the third (which I duplicated before and after the other 2) will not show for some reason?
Also, they are not equidistant apart - how can I get them an equal spacing apart?
Please help
NOTE: Instead of images there are red circles, just for visibility reasons.
Apply float: left on images themself, not on container:
/*--- Circular images --- */
.img-circular1, .img-circular2, .img-circular3{
/*width: 200px;*/
/*height: 200px;*/
width: 100px;
height: 100px;
background-size: cover;
display: block;
border-radius: 100px;
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
float: left;
}
.img-circular1{
background-image: url('/Imageslearn.jpg');
background: #aaa; /*added to as an alternative to image*/
}
.img-circular2{
background-image: url('/Images/watch.jpg');
background: #aaa; /*added to as an alternative to image*/
}
.img-circular3{
background-image: url('/Images/practice.jpg');
background: #aaa; /*added to as an alternative to image*/
}
.container1{
left: 15%;
width: 70%;
/* float: left; */
height: 300px;
position: relative;
}
<div class="container1">
<div class="img-circular1"></div>
<div class="img-circular2"></div>
<div class="img-circular3"></div>
</div>
To answer your second question:
wrap circles in some other div
make their width be some percentage value and float them left
set margin on circles to margin: 0 auto.
Here is prototype for you to study:
#green {
background: green;
padding: 10px;
overflow: auto;
}
#blue {
background: blue;
width: 50%;
float: left;
border: 1px solid #fff;
box-sizing: border-box; /*good for when there is border or padding*/
}
#red {
background: red;
width: 100px;
height: 100px;
border-radius: 50%;
margin: 0 auto;
}
<div id="green">
<div id="blue">
<div id="red"></div>
</div>
<div id="blue">
<div id="red"></div>
</div>
<div id="blue">
<div id="red"></div>
</div>
<div id="blue">
<div id="red"></div>
</div>
</div>
I updated your code to use FlexBox. Since you want your circles to be equally spaced across the row, float: left won't help much. I had to add a wrapper div around each circle div so that it could expand to fill the space without distorting the circles.
/*--- Circular images --- */
.img-circular1,
.img-circular2,
.img-circular3 {
width: 200px;
height: 200px;
background-size: cover;
border-radius: 100px;
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
background: red;
display: block;
margin: 0 auto;
}
.img-circular1 {
background-image: url('/Images/learn.jpg');
}
.img-circular2 {
background-image: url('/Images/watch.jpg');
}
.img-circular3 {
background-image: url('/Images/practice.jpg');
}
#container1 {
top: 100px;
position: relative;
margin-left: auto;
margin-right: auto;
width: 70%;
background-color: green;
overflow: auto;
bottom: 0;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.wrap {
flex-grow: 1;
}
<div id="container1" style="padding-bottom: 500px;">
<div class="wrap">
<div class="img-circular1"></div>
</div>
<div class="wrap">
<div class="img-circular2"></div>
</div>
<div class="wrap">
<div class="img-circular3"></div>
</div>
<div class="wrap">
<div class="img-circular1"></div>
</div>
</div>
Related
i have the below structure on my website and there are alternating float:left and float:right assigned to these div containers. But now I want all these divs not to appear side by side (as they do right now) but one below the other
html
<div class="chat">
<div class="chat-message a">...</div>
<div class="chat-message b">...</div>
<div class="chat-message a">...</div>
<div class="chat-message b">...</div>
</div>
css
.chat{
min-height: 100px;
max-height: 600px;
height: 600px;
overflow-y: scroll;
position: relative;
}
.chat-message{
background-color: #D3D3D3;
max-width: 90%;
margin: 20px 15px 0 15px;
border-radius: 8px;
}
.a{
float: left;
background-color: #79d2a1;
}
.b{
float: right;
background-color: #7eaacd;
}
Add clear: both; to the chat-message class, as follows:
.chat{
min-height: 100px;
max-height: 600px;
height: 600px;
overflow-y: scroll;
position: relative;
}
.chat-message{
background-color: #D3D3D3;
max-width: 90%;
margin: 20px 15px 0 15px;
border-radius: 8px;
clear: both;
}
.a{
float: left;
background-color: #79d2a1;
}
.b{
float: right;
background-color: #7eaacd;
}
<div class="chat">
<div class="chat-message a">...</div>
<div class="chat-message b">...</div>
<div class="chat-message a">...</div>
<div class="chat-message b">...</div>
</div>
you say : But now I want all these divs not to appear side by side
can you use bootstrap
<div class="col align-self-start"></div>
<div class="col align-self-end"></div>
<div class="col align-self-start"></div>
<div class="col align-self-end"></div>
<div class="col align-self-start"></div>
<div class="col align-self-end"></div>
Try Flexbox
.chat{
min-height: 100px;
max-height: 600px;
height: 600px;
overflow-y: scroll;
position: relative;
display:flex;
flex-direction: column;
}
.chat-message{
background-color: #D3D3D3;
max-width: 90%;
margin: 20px 15px 0 15px;
border-radius: 8px;
}
.a{
align-self: flex-start;
background-color: #79d2a1;
}
.b{
align-self: flex-end;
background-color: #7eaacd;
}
How can I center this image that I have in this div in a way that it won't move the 'line' div? I want the line to be touching the top of the square too.
.black {
background: black;
}
.square {
width: 200px;
height: 500px;
margin: 37px auto;
border-radius: 2px;
}
.image {
height: 60px;
width: 60px;
}
.line {
width: 4px;
height: 500px;
background-color: red;
}
<div class="container">
<div class="square black">
<img class="image" src="https://c.neh.tw/thumb/f/720/5659673474629632.jpg">
<div class="wrapper">
<div class="line"></div>
<div class="rectangle"></div>
</div>
</div>
Here is one way to prevent it from disrupting the flow layout of your container:
you can make the container a position of relative, and the image a position of absolute, positioned off the top and left by 50%, then transform it so that the center of the image is in the center position.
You could also just make the image a background-image of the div instead of using an image element, which may be easier to manipulate.
.black {
background: black;
}
.square {
position: relative;
width: 200px;
height: 500px;
margin: 37px auto;
border-radius: 2px;
}
.image {
height: 60px;
width: 60px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.line {
width: 4px;
height: 500px;
background-color: red;
}
<div class="container">
<div class="square black">
<img class="image" src="https://c.neh.tw/thumb/f/720/5659673474629632.jpg">
<div class="wrapper">
<div class="line"></div>
<div class="rectangle"></div>
</div>
</div>
</div>
I'm not sure I understand your exact desired end goal. But, if I understand correctly, you could create a flex parent to justify the image, and then position the line absolutely within that. See -
.black {
background: black;
}
.square {
width: 200px;
height: 500px;
margin: 37px auto;
border-radius: 2px;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
.image {
height: 60px;
width: 60px;
}
.line {
width: 4px;
background-color: red;
position: absolute;
left: 0;
top: 0;
bottom: 0
}
<div class="square black">
<div class="line"></div>
<img class="image" src="https://c.neh.tw/thumb/f/720/5659673474629632.jpg">
</div>
You can just use these css for .square and .image
.square {
width: 200px;
height: 500px;
margin: 37px auto;
border-radius: 2px;
position: relative;
}
.image {
height: 60px;
width: 60px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
You can easily center a image by using CSS position absolute. By making the position of square black class "absolute" and apply to properties "top: 45%;" and "left: 47%" . By applying this your problem will be definitely solve.
.black {
background: black;
}
.square {
display: flex;
align-item: center;
justify-content: center;
width: 200px;
height: 500px;
border-radius: 2px;
}
.image {
height: 60px;
width: 60px;
}
<div class="container">
<div class="square black">
<img class="image" src="https://c.neh.tw/thumb/f/720/5659673474629632.jpg">
</div>
</div>
.black {
background: black;
}
.square {
position: absolute;
top: 45%;
left: 47%;
width: 200px;
height: 500px;
margin: 37px auto;
border-radius: 2px;
}
.image {
height: 60px;
width: 60px;
position: absolute;
top:50%;
left:50%;
}
.line {
width: 4px;
height: 500px;
background-color: red;
}
<div class="container">
<div class="square black">
<img class="image" src="https://c.neh.tw/thumb/f/720/5659673474629632.jpg">
<div class="wrapper">
<div class="line"></div>
<div class="rectangle"></div>
</div>
</div>
.black {
background: black;
}
.square {
width: 200px;
height: 500px;
margin: 37px auto;
border-radius: 2px;
}
.image {
height: 60px;
width: 60px;
}
.line {
width: 4px;
height: 500px;
background-color: red;
}
<div class="container">
<div class="square black">
<img class="image" src="https://c.neh.tw/thumb/f/720/5659673474629632.jpg">
<div class="wrapper">
<div class="line"></div>
<div class="rectangle"></div>
</div>
</div>
I'm trying to do a container with rounded corners, basically it will have a rounded corner on the top-left of the header(red) and then it should have it on the bottom left of the view that we have....
so what it is hard for me is the following:
the bottom border should be rounded if it is the end of the page
the border should keep straight if it isn't the end of the page.
so what I have is the following, if you see this example, the bottom left corner is rounded because the content (yellow) is not bigger than 100% therefore we show the rounded corner and also we complete the view so the corner is stick to the bottom.
html {
height: 100%;
}
body {
height: 100%;
margin: 0;
background: black;
}
.header {
height: 25px;
margin-left: 20%;
width: 80%;
background: red;
border-top-left-radius: 10px;
}
.main {
display: block;
height: calc(100% - 25px);
margin-left: 20%;
width: 80%;
background: green;
overflow: scroll;
border-bottom-left-radius: 10px;
overflow-x: hidden;
}
.content {
height: 30px;
width: 100%;
background: yellow;
}
<body>
<div class="header">
header
</div>
<div class="main">
<div class="content"></div>
</div>
</body>
the problem is when the content is bigger than the main as you can see, it will always be rounded as the following example and the height of the content is larger than the main so it should continue the line and show the corner only if the user scrolls down
html {
height: 100%;
}
body {
height: 100%;
margin: 0;
background: black;
}
.header {
height: 25px;
margin-left: 20%;
width: 80%;
background: red;
border-top-left-radius: 10px;
}
.main {
display: block;
height: calc(100% - 25px);
margin-left: 20%;
width: 80%;
background: green;
overflow: scroll;
border-bottom-left-radius: 10px;
overflow-x: hidden;
}
.content {
height: 900px;
width: 100%;
background: yellow;
}
<body>
<div class="header">
header
</div>
<div class="main">
<div class="content"></div>
</div>
</body>
I also did some test using the rounder corner on the content, but if the content is smaller it will show the rounded corner in the wrong place.
html {
height: 100%;
}
body {
height: 100%;
margin: 0;
background: black;
}
.header {
height: 25px;
margin-left: 20%;
width: 80%;
background: red;
border-top-left-radius: 10px;
}
.main {
display: block;
height: calc(100% - 25px);
margin-left: 20%;
width: 80%;
background: green;
overflow: scroll;
overflow-x: hidden;
border: 1px solid violet;
}
.content {
height: 90px;
width: 100%;
background: white;
border-bottom-left-radius: 10px;
border: 1px solid red;
}
<body>
<div class="header">
header
</div>
<div class="main">
<div class="content"></div>
</div>
</body>
I'm not the best at scss(clearly :P) so I would appreciate your help.
is there a way to achieve this with only css or should I just use javascript?
I am trying to wrap my right div around my left, in an inverse moon shape? Here's what it looks like right now.
What I want to do is have the red block wrap around the rounder corners of the black block. Here is the current HTML/CSS code, I apologize if the CSS code is a little "messy" as i have been experimented different codes.
HTML
<div class="container full-width">
<div class="row proj">
<div class="col-md-8 full-width">
<div class="content">
</div>
</div>
<div class="col-md-4 full-width">
<div class="options">
</div>
</div>
</div>
</div>
CSS
.content {
margin-top: 75px;
position: relative;
width: 70vw;
max-width: 100%;
height: 90vh;
max-height: 100%;
overflow: hidden;
background-color: black;
border-radius: 0 50vw 50vw 0;
}
.options {
margin-top: 75px;
position: relative;
width: 30vw;
max-width: 100%;
height: 90vh;
max-height: 100%;
overflow: hidden;
background-color: red;
}
.container .full-width{
padding-left: 0;
padding-right: 0;
overflow-x: hidden;
}
UPDATE
Answer Found, thanks for the help, so had to tweak the code a bit from your posted code, it looks like this now.
.content {
margin-top: 75px;
width: 30vw;
height: 90vh;
overflow: hidden;
background-color: black;
border-radius: 0 50vw 50vw 0;
float:left;
position:relative;
z-index:2;
}
.options {
margin-top: 75px;
margin-left:3%;
position:relative;
float:right;
width: 30vw;
height: 90vh;
max-height: 100%;
overflow: hidden;
background-color: red;
}
.container .full-width{
position: absolute;
padding-left: 0;
padding-right: 0;
}
and the final result looks like this, will tweak the positioning some more but the result is what i wanted, thanks again.
UPDATE 2
Ok, had to make another edit, for some reason I had to float them both left. OTherwise if i kept the red div float right and tried to expand its width, it would expand to the left, any idea why? current code:
.content {
margin-top: 75px;
width: 44vw;
height: 90vh;
overflow: hidden;
background-color: black;
border-radius: 0 50vw 50vw 0;
float:left;
position:relative;
z-index:2;
}
.options {
margin-top: 75px;
margin-left:20%;
position:relative;
float:left;
width: 50vw;
height: 90vh;
max-height: 100%;
overflow: hidden;
background-color: red;
}
.container .full-width{
position: absolute;
padding-left: 0;
padding-right: 0;
}
Use position:relative; for content and position:absolute; for options
.content {
width: 30vw;
height: 90vh;
overflow: hidden;
background-color: black;
border-radius: 0 50vw 50vw 0;
float:left;
position:relative;
z-index:2;
}
.options {
margin-left:3%;
position:absolute;
float:right;
width: 30vw;
height: 90vh;
max-height: 100%;
overflow: hidden;
background-color: red;
}
<div class="container full-width">
<div class="row proj">
<div class="col-md-8 full-width">
<div class="content">
</div>
</div>
<div class="col-md-4 full-width">
<div class="options">
</div>
</div>
</div>
I want to create a footer where in the upper part there is a semi circle on the center with a logo inside of it. I have my sample code here, but the problem with it is that the logo is bound on the height of the footer div.
html,
body,
.container,
.content {
height: 100%;
}
.container,
.content {
position: relative;
}
.proper-content {
position: absolute;
padding-top: 40px;
/* >= navbar height */
}
.wrapper {
position: absolute;
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -100px;
/* same as the footer */
}
.push {
height: 100px;
/* same as the footer */
}
.footer-logo {
height: 200px;
width: 100%;
position: absolute;
background-image: url("gaslogo.png");
background-position: 10% 100%;
z-index: 999;
}
.footer-wrapper {
position: relative;
height: 200px;
background-color: red;
}
.halfCircleBottom {
position: relative;
height: 100px;
width: 250px;
border-radius: 0 0 100px 100px;
-moz-border-radius: 0 0 100px 100px;
-webkit-border-radius: 0 0 100px 100px;
background: white;
}
<head>
<link rel="stylesheet" type="text/css" href="test.css">
</head>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
</div>
</div>
</div>
<div class="container">
<div class="content">
<div class="logo"></div>
<div class="wrapper"></div>
<div class="push"></div>
</div>
<div class="footer-logo">dsad</div>
<div class="footer-wrapper">
<footer>
<center>
<div class="halfCircleBottom"></div>
</center>
</footer>
</div>
I used a :before pseudo element with background image for the circle.
.footer {
background: crimson;
height: 100px;
margin-top: 100px;
text-align: center;
}
.footer:before {
content: "";
display: inline-block;
vertical-align: top;
width: 100px;
height: 100px;
background: crimson url("https://i.stack.imgur.com/Fogjj.jpg") center / cover;
border: 10px solid white;
border-radius: 50%;
box-sizing: border-box;
margin-top: -50px;
}
<footer class="footer"></footer>
I accomplished what you need this way:
Changed your HTML a bit:
<div class="footer-wrap">
<div class="halfCircleBottom">
<img src="insert your image with the same width as the parent div"/>
</div>
<footer>
<center>
</center>
</footer>
</div><!--end footer wreap-->
Then added and changed one of your css declarations:
footer {
background: black;
height: 100px;
}
.halfCircleBottom{
position: absolute;
height: 250px;
width: 250px;
border-radius: 50%;
background: white;
left: 50%;
transform: translate(-50%, -72%);
}
Try this
HTML:
<div class="content">content</div>
<div class="footer"></div>
CSS:
.content{
height: 200px;
text-align: center;
background: #fff;
}
.footer{
height: 100px;
background: #cf9f3f;
position: relative;
text-align: center;
}
.footer:before{
content: '';
width: 100px;
text-align: center;
height: 100px;
border-radius: 50%;
background: #cf9f3f;
border: 4px solid #fff;
position: absolute;
left: 0;
right: 0;
margin: -52px auto 0;
}
Example: https://jsfiddle.net/vc4mvwd2/