Centering child divs within a parent div - html

I want the max width of the "circlecontainer" to be 300px.
but when the browser exceeds 1200px in width, I want my 4 child divs (with max width 300px) to stay centered in the browser.
They are currently positioned on the left side.
Here is my html and css.
any tips would be appreciated :)
.getstartedcirclescontainer {
height: 650px;
width: 100%;
display: flex;
text-align: center;
background-image: linear-gradient(#3329ff, white);
}
.circlecontainer {
height: 100%;
width: 24.9%;
padding-top: 175px;
background-color: rgba(0, 0, 0, 0.1);
max-width: 300px;
}
.circle1 {
height: 170px;
width: 170px;
border-radius: 50%;
background-image: linear-gradient(#8680ff, #5a52ff);
margin: 0 auto;
border-style: solid;
border-width: 2px;
border-color: #fff;
box-shadow: 0 10px 20px 0 rgba(0, 0, 0, .66);
}
<div class="getstartedcirclescontainer">
<div class="circlecontainer">
<div class="circle1">
</div>
</div>
<div class="circlecontainer">
<div class="circle1">
</div>
</div>
<div class="circlecontainer">
<div class="circle1">
</div>
</div>
<div class="circlecontainer">
<div class="circle1">
</div>
</div>
</div>

Just replace text-align: center; with justify-content: center; for .getstartedcirclescontainer.
HTML:
<div class="getstartedcirclescontainer">
<div class="circlecontainer">
<div class="circle1">
</div>
</div>
<div class="circlecontainer">
<div class="circle1">
</div>
</div>
<div class="circlecontainer">
<div class="circle1">
</div>
</div>
<div class="circlecontainer">
<div class="circle1">
</div>
</div>
</div>
CSS:
.getstartedcirclescontainer {
height: 650px;
width: 100%;
display: flex;
justify-content: center;
background-image: linear-gradient(#3329ff, white);
}
.circlecontainer {
height: 100%;
width: 24.9%;
padding-top: 175px;
background-color: rgba(0, 0, 0, 0.1);
max-width: 300px;
}
.circle1 {
height: 170px;
width: 170px;
border-radius: 50%;
background-image: linear-gradient(#8680ff, #5a52ff);
margin: 0 auto;
border-style: solid;
border-width: 2px;
border-color: #fff;
box-shadow: 0 10px 20px 0 rgba(0,0,0,.66);
}

Related

How to apply childs to before in css

I have four blocks where I specified before, in order to change the radius of the central block using before, the problem is that all my blocks are purple, I need to apply different colors for all blocks, for example blue, yellow, red, green, I guess what is needed use childs for this example, but I don't quite understand how to implement it
.EnjoyGirlsContainer {
text-align: center;
}
.EnjoyGirlsList {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.EnjoyGirlsList div img {
width: 240px;
height: 304px;
max-width: 100%;
margin: 20px 5px 5px 5px;
margin-right: 0;
margin-left: 0;
}
.EnjoyCardContainer {
position: relative;
margin: 7px;
margin-right: 0;
margin-left: 0;
}
.EnjoyCardChildContainer {
position: absolute;
width: 100%;
bottom: 5px;
background: purple;
}
.EnjoyCardChildContainer:after {
content: '';
position: absolute;
left: 0;
width: 100%;
border-left: 120px solid transparent;
border-right: 120px solid transparent;
box-sizing: border-box;
border-top: 8px solid purple;
}
.EnjoyCardChildContainer:first-child:before {
border-top: 8px solid red;
}
.EnjoyCard {
margin-right: 10px;
margin-left: 10px;
}
.EnjoyCardChildContainer h3 {
font-size: 30px;
}
<div class="EnjoyGirlsList">
<div class="EnjoyCard">
<div>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/A-Team-Logo.svg/1200px-A-Team-Logo.svg.png" alt="">
</div>
<div class="EnjoyCardContainer">
<div class="EnjoyCardChildContainer">
<h3>Hello World</h3>
</div>
</div>
</div>
<div class="EnjoyCard">
<div>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/A-Team-Logo.svg/1200px-A-Team-Logo.svg.png" alt="">
</div>
<div class="EnjoyCardContainer">
<div class="EnjoyCardChildContainer">
<h3>Hello World</h3>
</div>
</div>
</div>
<div class="EnjoyCard">
<div>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/A-Team-Logo.svg/1200px-A-Team-Logo.svg.png" alt="">
</div>
<div class="EnjoyCardContainer">
<div class="EnjoyCardChildContainer">
<h3>Hello World</h3>
</div>
</div>
</div>
<div class="EnjoyCard">
<div>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/A-Team-Logo.svg/1200px-A-Team-Logo.svg.png" alt="">
</div>
<div class="EnjoyCardContainer">
<div class="EnjoyCardChildContainer">
<h3>Hello World</h3>
</div>
</div>
</div>
</div>
.EnjoyCard:nth-child(1) .EnjoyCardChildContainer:after {
filter: drop-shadow(0 1px 4px rgba(223, 8, 8, 0.967));
border-top: 8px solid yellow;
}

scaling individual images into grid squares?

Hello I'm pretty new to this & I'm trying to figure out how to scale and clip these images to fit into each grid square without having a border...
I also don't know if this is an effective way to set up my images. I'd like to have a different image for each square, but how it's set up now I'd have to make a new .box .inner# for each one. If there is a better way to structure this that'd be really helpful.
.grid {
margin: 0 auto;
width: 240vw;
max-width: 200vh;
height: 240vw;
max-height: 200vh;
font-size: 2rem;
}
.row {
display: flex;
}
.box {
background: red;
margin: 5px;
color: white;
font-weight: bold;
flex: 1 0 auto;
position: relative;
}
.box:after {
content: "";
float: left;
display: block;
padding-top: 100%;
}
.box .inner1 {
background-image: url("https://c1.staticflickr.com/2/1763/29556413048_164120ccb5_b.jpg");
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
display: flex;
align-items: center;
justify-content: center;
text-shadow: 0px 0px 8px rgb(36, 36, 36), 0px 0px 20px rgba(0, 0, 0, 0.9);
}
.box .inner2 {
background-image: url("https://c1.staticflickr.com/1/922/43509246041_043aff0334_h.jpg");
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
display: flex;
align-items: center;
justify-content: center;
text-shadow: 0px 0px 8px rgb(36, 36, 36), 0px 0px 20px rgba(0, 0, 0, 0.9);
}
<div class="grid">
<div class="row">
<div class="box">
<div class="inner1">1</div>
</div>
<div class="box">
<div class="inner1">2</div>
</div>
<div class="box">
<div class="inner1">3</div>
</div>
<div class="box">
<div class="inner1">4</div>
</div>
</div>
<div class="row">
<div class="box">
<div class="inner2">5</div>
</div>
<div class="box">
<div class="inner2">6</div>
</div>
<div class="box">
<div class="inner2">7</div>
</div>
<div class="box">
<div class="inner2">8</div>
</div>
</div>
</div>
You might do it like this:
.grid {
margin: 0 auto;
width: 240vw;
max-width: 200vh;
height: 240vw;
max-height: 200vh;
font-size: 2rem;
}
.row {
display: flex;
}
.box {
background: red;
margin: 5px;
color: white;
font-weight: bold;
flex: 1 0 auto;
position: relative;
}
.box:after {
content: "";
float: left;
display: block;
padding-top: 100%;
}
.box > div {
background-size:cover;
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
display: flex;
align-items: center;
justify-content: center;
text-shadow: 0px 0px 8px rgb(36, 36, 36), 0px 0px 20px rgba(0, 0, 0, 0.9);
}
.inner1 {
background-image: url("https://c1.staticflickr.com/2/1763/29556413048_164120ccb5_b.jpg");
}
.inner2 {
background-image: url("https://c1.staticflickr.com/1/922/43509246041_043aff0334_h.jpg");
}
.inner3 {
background-image: url("https://picsum.photos/200/200?3");
}
.inner4 {
background-image: url("https://picsum.photos/200/200?4");
}
.inner5 {
background-image: url("https://picsum.photos/200/300?5");
}
.inner6 {
background-image: url("https://picsum.photos/200/300?6");
}
.inner7 {
background-image: url("https://picsum.photos/200/200?7");
}
.inner8 {
background-image: url("https://picsum.photos/200/300?8");
}
<div class="grid">
<div class="row">
<div class="box">
<div class="inner1">1</div>
</div>
<div class="box">
<div class="inner2">2</div>
</div>
<div class="box">
<div class="inner3">3</div>
</div>
<div class="box">
<div class="inner4">4</div>
</div>
</div>
<div class="row">
<div class="box">
<div class="inner5">5</div>
</div>
<div class="box">
<div class="inner6">6</div>
</div>
<div class="box">
<div class="inner7">7</div>
</div>
<div class="box">
<div class="inner8">8</div>
</div>
</div>
</div>
I am not fully sure if this will fix your problem but maybe take off the margin in your .box class in your css file.
not enough reputation yet so click this link
Instead of having your margin at 5px change it to 0px and see if that helps.
As for the different images you just need to create a new class for each image an link a new image to that class, go back and link it up like you have with the two previous.

flex box centering not working

So I have been working with flex box recently and have the hand of positioning but justification is still being difficult.
I want X images to sit side by side in flex boxes, and then wrap when the page gets too small for them. This all works fine. However what isn't happening is the images inside the flex box aren't centering horizontally. I have tried every combo of justify-content, align-items, align-self etc to get it to work but I appear to be missing something.
here is the code
body {
background: black;
}
.general_peer_request_display {
display: flex;
flex-direction: row;
flex-wrap: wrap;
padding: 10px;
}
.general_peer_request_box {
flex: 1 1 90px;
padding: 5px;
align-items: center;
justify-content: center;
}
.general_peer_request_image {
width: 80px;
height: 80px;
border-radius: 50% 50% 50% 50%;
border: 3px double white;
background: blue;
}
.general_peer_request_text {
opacity: 0;
padding: 3px 5px 3px 0px;
text-align: left;
padding: 15px 5px 15px 5px;
width: 80px;
}
.general_peer_request_text:hover {
opacity: 1;
color: rgba(255, 255, 255, 1);
text-shadow: 1px 1px white;
cursor: pointer;
}
<div class="general_peer_request_display">
<div class="general_peer_request_box">
<div class="general_peer_request_image" style="background: url('') center no-repeat;">
<div class="general_peer_request_text">Neo</div>
</div>
</div>
<div class="general_peer_request_box">
<div class="general_peer_request_image" style="background: url('') center no-repeat;">
<div class="general_peer_request_text">Neo</div>
</div>
</div>
<div class="general_peer_request_box">
<div class="general_peer_request_image" style="background: url('') center no-repeat;">
<div class="general_peer_request_text">Neo</div>
</div>
</div>
<div class="general_peer_request_box">
<div class="general_peer_request_image" style="background: url('') center no-repeat;">
<div class="general_peer_request_text">Neo</div>
</div>
</div>
</div>
Thank you.
You simply need to add margin:auto inside the boxes OR make their container display:flex (what you forgot)
body {
background: black;
}
.general_peer_request_display {
display: flex;
flex-direction: row;
flex-wrap: wrap;
padding: 10px;
}
.general_peer_request_box {
flex: 1 1 90px;
padding: 5px;
/* Or this instead of margin auto
display:flex;
align-items: center;
justify-content: center;
*/
}
.general_peer_request_image {
width: 80px;
height: 80px;
border-radius: 50% 50% 50% 50%;
border: 3px double white;
background: blue;
margin:auto; /*Added this*/
}
.general_peer_request_text {
opacity: 0;
padding: 3px 5px 3px 0px;
text-align: left;
padding: 15px 5px 15px 5px;
width: 80px;
}
.general_peer_request_text:hover {
opacity: 1;
color: rgba(255, 255, 255, 1);
text-shadow: 1px 1px white;
cursor: pointer;
}
<div class="general_peer_request_display">
<div class="general_peer_request_box">
<div class="general_peer_request_image" style="background: url('') center no-repeat;">
<div class="general_peer_request_text">Neo</div>
</div>
</div>
<div class="general_peer_request_box">
<div class="general_peer_request_image" style="background: url('') center no-repeat;">
<div class="general_peer_request_text">Neo</div>
</div>
</div>
<div class="general_peer_request_box">
<div class="general_peer_request_image" style="background: url('') center no-repeat;">
<div class="general_peer_request_text">Neo</div>
</div>
</div>
<div class="general_peer_request_box">
<div class="general_peer_request_image" style="background: url('') center no-repeat;">
<div class="general_peer_request_text">Neo</div>
</div>
</div>
</div>

get only one division center in one row class using bootstrap

i have one class row in my web page and in that class i have one division but i want to display that division in center however m not able to done this.
this is my simple row class.
<div class="row">
<div id="left" class="col-md-6">
<div id="leftin" class="col-md-6"></div>
</div>
<div id="right" class="col-md-6"></div>
</div>
and my css
#left
{
height: 150px;
}
#leftin
{
background: url(news_image_04.jpg) no-repeat;
background-size: 100% 100%;
height: 150px;
margin: 0 auto;
}
#right
{
background: url("news_image_03.jpg") no-repeat;
background-size: 100% 100%;
height: 150px;
}
i want to center leftin division under left division
Just make the float none of this.
#leftin {
background: rgba(0, 0, 0, 0) url("news_image_04.jpg") no-repeat scroll 0 0 / 100% 100%;
border: 1px solid black;
float: none; /* make the float none */
height: 150px;
margin: 0 auto;
}
#left
{
height: 150px;
border:1px solid red;
}
#leftin {
background: rgba(0, 0, 0, 0) url("news_image_04.jpg") no-repeat scroll 0 0 / 100% 100%;
border: 1px solid black;
float: none; /* make the float none */
height: 150px;
margin: 0 auto;
}
#right
{
background: url("news_image_03.jpg") no-repeat;
background-size: 100% 100%;
height: 150px;
border:1px solid purple;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div id="left" class="col-md-6">
<div id="leftin" class="col-md-6"></div>
</div>
<div id="right" class="col-md-6"></div>
</div>
For leftin remove class="col-md-6" and add width 50%
<div class="row">
<div id="left" class="col-md-6">
<div id="leftin"></div>
</div>
<div id="right" class="col-md-6"></div>
</div>
#leftin
{
background: url(news_image_04.jpg) no-repeat;
background-size: 100% 100%;
height: 150px;
margin: 0 auto;
width:50%;
}
add class to col-md-offset-3 div with id leftin
like below
<div id="leftin" class="col-md-6 col-md-offset-3"> </div>
Updated to your example
#left
{
height: 150px;
}
#leftin
{
background: url(news_image_04.jpg) no-repeat;
background-size: 100% 100%;
height: 150px;
margin: 0 auto;
}
#right
{
background: url("news_image_03.jpg") no-repeat;
background-size: 100% 100%;
height: 150px;
}
<div class="row">
<div id="left" class="col-md-6">
<div id="leftin" class="col-md-6 col-md-offset-3"></div>
</div>
<div id="right" class="col-md-6"></div>
</div>

How to center 3 divs horizontally with itselfs?

I'm facing a problem:
I want to put 3 divs horizontally with itself, but i'm not getting to do it right.
Could someone help?
I've already searched a lot about properties in css and html, but i couldn't apply to what i'm doing.
With the normal zoom:
http://i.imgur.com/ylk5pm2.png
What i want:
http://i.imgur.com/47kzlpv.png
Codes:
.container {
width:100%;
border-color: #FF0000;
border-style: solid;
border-width:medium;
text-align:center;
margin-bottom: 1%;
}
.menu_box_filtro{
display:inline;
}
.conteudo_box_filtro{
display:inline-block;
}
<div class="border_preta">
<div class="menu_box_filtro">
<div class="grid_10 border_brown conteudo_box_filtro">
</div>
</div>
<div class="menu_box_filtro">
<div class="grid_63 border_brown conteudo_box_filtro">
menu centro
</div>
</div>
<div class="menu_box_filtro">
<div class="grid_10 border_brown conteudo_box_filtro">
menu direita
</div>
</div>
</div>
You can check with the below link.
Fiddle
<div class="main">
<div class="inner">
<div class="left-col">Left</div>
<div class="center-col">Center</div>
<div class="right-col">Right</div>
</div>
Check this
.container{
width: 90%;
max-width: 900px;
margin: 0 auto;
background-color:#F0A202;
}
.group{
content:"";
display:table;
clear:both;
}
div:nth-of-type(1) {
width: 36%;
float: left;
}
div:nth-of-type(2) {
width: 30%;
float: left;
margin-left: 4%;
}
div:nth-of-type(3) {
width: 26%;
float: right;
}
<div class="container group">
<div>
<p>First<p>
</div>
<div>
<p>Second<p>
</div>
<div>
<p>Third<p>
</div>
</div>
Here is an example using FlexBox.
.container {
width: 100%;
border-color: #FF0000;
border-style: solid;
border-width: medium;
display: flex;
align-items: center;
}
.container>* {
flex-grow: 1;
}
.menu_box.left {
background-color: rgba(255, 0, 0, 0.5);
height: 100px;
}
.menu_box.center {
background-color: rgba(0, 255, 0, 0.5);
height: 200px;
}
.menu_box.right {
background-color: rgba(0, 0, 255, 0.5);
height: 100px;
}
<div class="container">
<div class="menu_box left">Left</div>
<div class="menu_box center">Center</div>
<div class="menu_box right">Right</div>
</div>