I am trying to make the container responsive, but while going through developer options and checking in responsive mode, the container did not get placed correctly. I have simply added the margins to the button of the colors on the left side of the container. I am attaching the code and screenshots for reference.
.color_selector {
align-items: center;
position: absolute;
height: 516px;
width: 59%;
background-color: black;
border-radius: 10px;
}
.grey_btn {
border-radius: 50%;
width: 51px;
height: 51px;
margin-top: 35px;
margin-right: 800px;
background-color: grey;
border: 3px solid white;
}
.grey_btn:hover {
border: 3px solid #5998f7;
}
.blue_btn {
border-radius: 50%;
width: 51px;
height: 51px;
margin-right: 800px;
margin-top: 15px;
background-color: #1f316b;
border: 3px solid white;
}
.blue_btn:hover {
border: 3px solid #5998f7;
}
.brown_btn {
border-radius: 50%;
width: 51px;
height: 51px;
margin-right: 800px;
margin-top: 15px;
background-color: #57191a;
border: 3px solid white;
}
.brown_btn:hover {
border: 3px solid #5998f7;
}
.white_btn {
border-radius: 50%;
width: 51px;
height: 51px;
margin-right: 800px;
margin-top: 15px;
background-color: #e8e8e8;
border: 3px solid white;
}
.white_btn:hover {
border: 3px solid #5998f7;
}
<div class="color_selector">
<button class="grey_btn"></button>
<br></br>
<button class="blue_btn"></button>
<br></br>
<button class="white_btn"></button>
<br></br>
<button class="brown_btn"></button>
</div>
How do i make it responsive, the buttons and the container?
For starters, remove the absolute positioning on .color_selector. Then you can use a media query to adjust the container size on smaller devices. See the example below.
.color_selector {
align-items: center;
height: 516px;
width: 50%;
background-color: black;
border-radius: 10px;
}
/* sample media query */
#media only screen and (max-width: 800px) {
.color_selector {
width: 100%;
}
}
.grey_btn {
border-radius: 50%;
width: 51px;
height: 51px;
margin-top: 35px;
margin-right: 800px;
background-color: grey;
border: 3px solid white;
}
.grey_btn:hover {
border: 3px solid #5998f7;
}
.blue_btn {
border-radius: 50%;
width: 51px;
height: 51px;
margin-right: 800px;
margin-top: 15px;
background-color: #1f316b;
border: 3px solid white;
}
.blue_btn:hover {
border: 3px solid #5998f7;
}
.brown_btn {
border-radius: 50%;
width: 51px;
height: 51px;
margin-right: 800px;
margin-top: 15px;
background-color: #57191a;
border: 3px solid white;
}
.brown_btn:hover {
border: 3px solid #5998f7;
}
.white_btn {
border-radius: 50%;
width: 51px;
height: 51px;
margin-right: 800px;
margin-top: 15px;
background-color: #e8e8e8;
border: 3px solid white;
}
.white_btn:hover {
border: 3px solid #5998f7;
}
<div class="color_selector">
<button class="grey_btn"></button>
<button class="blue_btn"></button>
<button class="white_btn"></button>
<button class="brown_btn"></button>
</div>
Related
How they look like
i need the boxes to be near each other with a bit of space between but it doesn't seem to work, here's my code
HTMl:
<div className="RoundBox"></div>
<div className="RoundBox2"></div>
CSS:
.RoundBox {
border-radius: 10px;
border: 1.5px solid grey;
box-shadow: #e3eaf6;
width: 20vw;
height: 3vw;
float: left;
}
.RoundBox2 {
border-radius: 10px;
border: 1.5px solid grey;
box-shadow: #e3eaf6;
width: 20vw;
height: 3vw;
float: left;
padding-left: 20vw;
}
Add small amount of margin-left and margin-right like 2 or 3 pixels to both boxes.
.RoundBox {
border-radius: 10px;
border: 1.5px solid grey;
box-shadow: #e3eaf6;
width: 20vw;
height: 3vw;
float: left;
margin-left: 2px;
margin-right: 2px;
}
.RoundBox2 {
border-radius: 10px;
border: 1.5px solid grey;
box-shadow: #e3eaf6;
width: 20vw;
height: 3vw;
float: left;
padding-left: 20vw;
margin-left: 2px;
margin-right: 2px;
}
I am a middle school student experimenting around with CSS and HTML, and I noticed that width: calc(inherit) does something different than width: inherit.
The following snippet is what width: inherit; does.
.header {
background-color: #77a4ed;
min-width: 200px;
width: fit-content;
border-top-left-radius: 50px;
border-top-right-radius: 50px;
height: 30px;
text-align: center;
height: 20px;
}
.header > div {
background-color: whitesmoke;
border-right: solid 2px black;
border-left: solid 2px black;
border-top: solid 2px black;
min-width: 200px;
width: inherit;
text-align: center;
margin: auto;
padding-left: 10px;
padding-right: 10px;
padding-top: 3px;
padding-bottom: 3px;
}
.header > div:last-of-type {
background-color: whitesmoke;
border-right: solid 2px black;
border-left: solid 2px black;
min-width: 200px;
width: fit-content;
margin: auto;
padding-left: 10px;
border-bottom: solid 2px black;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
<div class='container'>
<div class='header'>
<div>
test
</div>
<div>
test..........................................................
</div>
</div>
</div>
This snippet is what width: calc(inherit); does.
.header {
background-color: #77a4ed;
min-width: 200px;
width: fit-content;
border-top-left-radius: 50px;
border-top-right-radius: 50px;
height: 30px;
text-align: center;
height: 20px;
}
.header > div {
background-color: whitesmoke;
border-right: solid 2px black;
border-left: solid 2px black;
border-top: solid 2px black;
min-width: 200px;
width: calc(inherit);
text-align: center;
margin: auto;
padding-left: 10px;
padding-right: 10px;
padding-top: 3px;
padding-bottom: 3px;
}
.header > div:last-of-type {
background-color: whitesmoke;
border-right: solid 2px black;
border-left: solid 2px black;
min-width: 200px;
width: fit-content;
margin: auto;
padding-left: 10px;
border-bottom: solid 2px black;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
<div class='container'>
<div class='header'>
<div>
test
</div>
<div>
test..........................................................
</div>
</div>
</div>
I don't understand why they would give different results. Could someone explain?
if you check the console.log you will see that calc doesn't work with inherit.
#a1{
width:inherit;
}
#a2{
width: calc (inherit);
}
<div id='a1'>xxx</div>
<div id='a2'>xxx</div>
calc() is suppose to calculate using a mathematical expression like -, +, *, or /
example
width: calc(100% - 100px);
you don't have any expression so it's probably not valid but maybe if you make the .header width have an expression then use the inherit that may work
.header{
width: cal(100% - 100px);
}
.header{
width: inherit;
}
that might work but not sure also I don't know if 100% - 100px is the exact width youre looking for
Just use width: 100% and it will take up the whole width of the parent element.
I'm a bit stuck on styling border around div box.
The problem is that I can't make borders not to be like:
Here is the real example what I have:
.num.num_1 {
border-left-color: #0D2431;
}
.num {
width: 60px;
height: 60px;
line-height: 50px;
border-width: 5px;
font-size: 40px;
}
.num {
float: left;
width: 40px;
height: 40px;
line-height: 36px;
text-align: center;
border: 2px solid #eee;
font-size: 20px;
color: #0D2431;
background-color: #fff;
}
div {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
vertical-align: baseline;
}
}
<div class="num num_1">1</div>
.num.cheat:before {
content:"";
position: absolute;
left: -5px;
right: -5px;
top: -5px;
bottom: -5px;
}
.num_1:before {
border-left: 5px solid black;
}
.num_2:before {
border-left: 5px solid black;
border-top: 5px solid black;
}
.num_3:before {
border-left: 5px solid black;
border-top: 5px solid black;
border-right: 5px solid black;
}
.num_4:before {
border-left: 5px solid black;
border-top: 5px solid black;
border-right: 5px solid black;
border-bottom: 5px solid black;
}
.num {
width: 60px;
height: 60px;
line-height: 50px;
border-width: 5px;
font-size: 40px;
position: relative;
margin-right: 10px;
}
.num {
float: left;
width: 40px;
height: 40px;
line-height: 36px;
text-align: center;
border: 5px solid #eee;
font-size: 20px;
color: #0D2431;
background-color: #fff;
}
div {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
vertical-align: baseline;
}
}
<div class="num num_1 cheat">1</div>
<div class="num num_2 cheat">2</div>
<div class="num num_3 cheat">3</div>
<div class="num num_4 cheat">4</div>
I modified your css a little bit. I solved it using the :before pseudo element.
Better yet, you can use box-shadow to achieve this without any extra elements.
See: http://jsfiddle.net/w3b1uh7g/2/
.num {
border-left: 0px;
box-shadow: -5px 0 0 0 #0D2431;
}
You can do a weird series of nested divs:
.border {
background: green;
padding: 10px 10px 10px 0;
display: inline-block;
}
.border-left {
padding-left: 10px;
background: black;
display: inline-block;
}
.inside-box {
background: red;
height: 100px;
width: 100px;
}
<div class="border-left">
<div class="border">
<div class="inside-box">1</div>
</div>
</div>
Just add these to your css. the Pseudo Elements should make it square without adding extra divs in the HTML
.num.num_1:before {
content: "";
position: relative;
display: block;
top: -5px;
left: -5px;
height: 5px;
width: 5px;
background: black;
}
.num.num_1:after {
content: "";
position: relative;
display: block;
bottom: 0px;
left: -5px;
height: 5px;
width: 5px;
background: black;
}
I'm trying to make it so the boxes are next to each other, but when I add another box it goes to the bottom. I'm fairly new to html and css, how would you do that? If you could code that part for me and explain it, I'd be really grateful.
Image:
http://i61.tinypic.com/9lj0ox.png
<div id="leftside">
<div id="portrait"></div>
<div id="leftbox"><b>About Me</b><p>test</p></div>
<style>
#leftside {
position: fixed;
margin-left: 0px;
top: 125px;
width: 220px;
height: 485px;
padding: 20px;
background: rgba(255,255,255,0.5);
background-repeat: repeat;
background-attachment: fixed;
border: 1px solid #000;
border-radius: 5px;
}
#portrait {
margin-left: 0px;
width: 200px;
height: 200px;
padding: 10px;
background: url(http://i861.photobucket.com/albums/ab179/treeskywind/profile/kidosmall2_zps57444730.png );
border: 1px solid #000;
border-radius: 5px;
color: #fff;
font-family: Century Gothic;
}
#leftbox {
height: 230px;
width: 200px;
margin-left: 0px;
margin-top: 20px;
background-color: #6855A7;
color: #fff;
border: 1px solid #000;
border-radius: 5px;
padding: 10px;
font-family: Century Gothic;
text-align: justified;
overflow: auto;
}
</style>
</div>
<div id="rightside">
<div id="box1"><b>Links</b></div>
<div id="rightbox"><b>My Interests</b></div>
<div id="box2">test</div>
<style>
#rightside {
position: fixed;
margin-left: 0px;
top: 125px;
width: 600px;
height: 485px;
padding: 20px;
background: rgba(255,255,255,0.5);
background-repeat: repeat;
background-attachment: fixed;
border: 1px solid #000;
border-radius: 5px;
margin-left: 280px;
}
#box1 {
margin-left: 0px;
width: 200px;
height: 160px;
padding: 10px;
background: #6855A7;
border: 1px solid #000;
border-radius: 5px;
color: #fff;
font-family: Century Gothic;
}
#rightbox {
height: 260px;
width: 200px;
margin-left: 0px;
margin-top: 20px;
background-color: #6855A7;
color: #fff;
border: 1px solid #000;
border-radius: 5px;
padding: 10px;
font-family: Century Gothic;
text-align: justified;
overflow: auto;
}
#box2 {
width: 200px;
height: 160px;
padding: 10px;
background: #6855A7;
border: 1px solid #000;
border-radius: 5px;
color: #fff;
font-family: Century Gothic;
margin-left: 250px;
}
</style>
</div>
you can use:
display: inline-block;
btw put your above your page html!!
First: I really tried to find an answer but non of them worked for me.
Here's my problem:
I have a base layout where I have a forward and a backward button in the footer.
Theses buttons must be quadratic. So I've decided to make them simple images (to avoid all the problems with trying to scaling divs propotionally).
Theses images have CSS:
.galleryFooterController {
position: relative;
height: 100%;
float: left;
margin-left: 5px;
background-color: #A0A0A0;
}
And are nested in a container with CSS:
#galleryFooterControlle {
position: absolute;
display: inline-block;
right: 15%;
background: white;
height: 100%;
padding-right: 5px;
width: auto;
}
But the container is not taking the correct width so that the images are not fitting inside and are rendered under each other. If I take out the height: 100% from the images, they fit next to each other in the container.
It would be great if you could help me finding a JS-free version to solve this problem!
Thanks!
Here is a FIDDLE that will give you a start.
I haven't made all of the divs line-up, but you can change the CSS to make it look prettier.
For your buttons, I just used div in a div with CSS-Tricks triangle - You can use .click on the outer div to run your function.
Here's the relevant CSS
.header {
width: 100%;
height: 50px;
background-color: #A0A0A0;
border: 4px solid white;
}
.container {
width: 90%;
height: 400px;
background-color: #A0A0A0;
border: 4px solid white;
float: left;
}
.rightbar {
width: 9%;
height: 460px;
border: 1px solid white;
float: right;
background-color: #A0A0A0;
}
.bottomholder {
width: 90%;
height: 50px;
border: 1px solid black;
}
.bottomleft {
height: 100%;
width: 562px;
float: left;
background-color: #A0A0A0;
border-left: 2px solid white;
}
.bottombutton {
height: 100%;
width: 130px;
float: left;
background-color: #A0A0A0;
border-left: 2px solid white;
}
.bottomright {
height: 100%;
width: 200px;
float: left;
background-color: #A0A0A0;
border-left: 2px solid white;
}
.arrowleft {
width: 40px;
height: 40px;
border-radius: 50%;
border: 4px solid white;
background-color: #A0A0A0;
float: left;
margin-left: 10px;
}
.arrow-left {
width: 0;
height: 0;
border-top: 15px solid transparent;
border-bottom: 15px solid transparent;
border-right: 15px solid black;
margin-left: 8px;
margin-top: 5px;
}
.arrowright {
width: 40px;
height: 40px;
border-radius: 50%;
border: 4px solid white;
background-color: #A0A0A0;
float: left;
margin-left: 10px;
}
.arrow-right {
width: 0;
height: 0;
border-top: 15px solid transparent;
border-bottom: 15px solid transparent;
border-left: 15px solid black;
margin-left: 15px;
margin-top: 5px;
}
Just i tried with liquid layout, removed the border 2px white and change the float property.
.header {
width: 98%;
height: 50px;
background-color: #A0A0A0;
margin:2px 2px;
}
.container{
width: 85%;
height: 400px;
background-color: #A0A0A0;
margin:2px 2px;
float: left;
}
.rightbar{
width: 12%;
height: 460px;
float: left;
background-color: #A0A0A0;
margin-top:2px;
margin-left: 2px;
padding-left: 3px;
}
Full Code http://jsfiddle.net/judearasu/5c5rq/
Thanks to everyone I figguered out how to solve the problem!
Because the images coudn't be rendered next to each other because its container would't pick the right width after scaling the images, i simply made the container width to the maximum available place which was in my project 85%. So now the images are fitting in!
Thanks again!