CSS Container fit to Child-Images - 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!

Related

How can I make this container responsive?

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>

Why does CSS width: calc(inherit) do something different than width: inherit?

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.

Position icon at the top right corner of a fieldset with legend

I'm having trouble making the below layout look the same across all browsers:
.wrapper {
margin-top: 100px;
position: relative;
height: 400px;
width: 400px;
border: 1px solid black;
}
.icon {
position: absolute;
width: 40;
height: 40px;
border: 1px solid black;
background-color: white;
top: -20px;
right: 10px;
}
<fieldset class="wrapper">
<legend>Legendary!</legend>
<div class="icon">icon</div>
</fieldset>
The problem is that when the legend element is present, the div.icon is pulled few pixels down on firefox, and a few pixels up on chrome. When I remove the legend element, it's working fine, but I can't do that. Any ideas on how to make it look the same everywhere?
here you have a working UPDATED :jsfiddle tested in chrome and firefox.
You don't need to work with position:absolute; you can just float:right; your div and give margin-top:-40px; or whatever value you want.
#wrapper{
margin-top: 100px;
position: relative;
height: 400px;
width: 400px;
border: 1px solid black;
}
#icon{
float:right;
background-color:#fff;
width:40px;
height:40px;
border:1px solid black;
margin-top:-20px;
margin-right:20px
}
legend#title {
margin-left: 20px;
float: left;
padding-left: 10px;
margin-top: -10px;
background: #f3f5f6;
width: 74px;
}
.icon {
float: right;
margin-top: -30px;
width: 40px;
height: 40px;
border: 1px solid black;
background-color: white;
}
tested on chrome as well as mozilla.
Try giving top value in percentage %.
.icon {
position: absolute;
width: 40;
height: 40px;
border: 1px solid black;
background-color: white;
top: -2.5%;
right: 10px;
}
Fiddle here: https://jsfiddle.net/37y8023g/
Use line-height for .icon
CSS:
.wrapper {
margin-top: 100px;
position: relative;
height: 400px;
width: 400px;
border: 1px solid black;
}
.icon {
position: absolute;
width: 40;
height: 40px;
border: 1px solid black;
background-color: white;
top: -20px;
right: 10px;
line-height: 40px;
}
Working example: https://jsfiddle.net/qjqv43y4/1/

I am using a 2 column template in Expression Web 4 - How do I keep sidebar equal sizes?

I attempted the solution that another person listed, and it kind of equaled it out, but because the content section grows depending on what I put in it, it looks goofy with the side bar staying the smaller size.
I am open to ideas, but I would rather have the column move with the content, such as floating up and down, or... At least show the same size...
The following is what I have in CSS now:
#import url("layout.css");
body {
font-family:"Georgia", "Times New Roman", Times, serif;
font-size: 0.8em;
background-color: #764;
background-image: url("../images/background.gif");
background-repeat: repeat;
background-attachment: scroll;
}
#container {
width: 700px;
margin: 10px auto;
}
#masthead {
text-align: center;
width: 698px;
border: 1px solid #431;
background-color: #fff;
background-image:;
background-attachment: scroll;
}
#navigation {
position: absolute;
float: left;
width: 148px;
height: 100%;
margin-top: 10px;
margin-bottom: 10px;
border: 1px solid #431;
background-color: #fff;
}
#content {
overflow: hidden;
float: right;
width: 518px;
margin:auto;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 10px;
padding: 10px;
border: 1px solid #431;
background-color: #fff;
}
#footer {
text-align: center;
clear: both;
width: 698px;
padding: 0px;
border: 1px solid #431;
background-color: #fff;
}
The webpage can be seen at http://www.crucifiedwithchrist.org.
Thanks,
John
define height
#navigation {
position: relative;
float: left;
width: 148px;
margin-top: 10px;
margin-bottom: 10px;
border: 1px solid #431;
background-color: #fff;
height: 730px;
}

automatic width of a div inside a div container

I have a design question.
I need to create a progress bar for a video player.
I have a div container (id videoManager) with all the div about the PLAY, the STOP, the progress bar, the VOLUME, other buttons, all one beside the other (floating left).
i would like the div of the progress bar (id playerSlider) resizes depending on the remained space. i wrote down this code, but if use "width: 100%;" for this div, it doesn't get the remained space, but the 100% of the container.
suggestions?
HTML:
<div id="videoManager">
<div id="playpauseCommand">Play</div>
<div id="stopCommand">Stop</div>
<div id="playerSlider">
<div id="objSlider"></div>
</div>
<div id="timeElement">10:12:12</div>
<div id="volumeSlider"></div>
<div id="displayCommand">Command</div>
</div>
CSS:
div#videoManager{
margin-top: 30px;
width: 980px;
height: 44px;
background: transparent url('bg.jpg') center center repeat-x;
position: relative;
color: #fff;
}
div#playpauseCommand, div#stopCommand{
width: 44px;
height: 44px;
float: left;
border-right: 2px solid #555;
}
div#playerSlider{
float:left;
height: 44px;
width: 100%;
padding: 15px 10px 0px 10px;
}
div#objectSlider{
float: left;
clear: left;
width: 100%;
}
div#timeElement{
float: left;
height: 44px;
width: 80px;
border-right: 2px solid #555;
}
div#volumeSlider{
float: left;
height: 44px;
width: 180px;
border-right: 2px solid #555;
}
div#displayCommand{
float: left;
height: 44px;
width: 70px;
border-right: 2px solid #555;
}
and this is a link to my site.
try this css code, not sure if this is exactly what you want though:
div#videoManager{
margin-top: 30px;
width: 980px;
height: 44px;
background: transparent url('bg.jpg') center center repeat-x;
position: relative;
color: #fff;
}
div#playpauseCommand, div#stopCommand{
width: 44px;
height: 44px;
float: left;
border-right: 2px solid #555;
}
div#playerSlider{
float:left;
height: 44px;
width: 53%;
padding: 15px 10px 0px 10px;
position:absolute;
left:178px;
}
div#objectSlider{
float: left;
clear: left;
width: 100%;
}
div#timeElement{
float: left;
height: 44px;
width: 80px;
border-right: 2px solid #555;
}
div#volumeSlider{
float: right;
height: 44px;
width: 180px;
border-right: 2px solid #555;
}
div#displayCommand{
float: right;
height: 34px;
width: 70px;
top:10px;
border-right: 2px solid #555;
position:relative;
}