How do I align these items properly? - css

I am currently working on a webpage featuring some jQuery-UI sliders, but I am having trouble properly aligning all of the things.
HTML:
<div class="row">
<div id="hue"><img src="download.png" class="hue" /></div>
<div id="mixedColor"></div>
</div>
<div class="rowVert">
<div class="vert" id="CSVhue"></div>
<div class="vert" id="CSVsat"></div>
<div class="vert" id="CSVbright"></div>
</div>
CSS:
#hue {
display: block;
width: 90%;
float: left;
margin: 0 auto;
margin-top: 37px;
}
.hue {
height: 12px;
width: 100%;
}
#mixedColor {
display: block;
width: 100px;
height: 100px;
border: 1px solid black;
float: right;
}
.vert {
margin-top: 100px;
}
But without any success.
Here is a JSFiddle: http://jsfiddle.net/npL866zz/1/
How I want it:
Please note my webpage is optimized for IE7, so all commands must be optimized for this one browser.

Here is something you could work with
Fiddle demo
#hue {
margin-top: 50px;
margin-right: 110px;
overflow: hidden;
}
.hue {
height: 17px;
width: 100%;
}
#mixedColor {
position: absolute;
right: 10px;
top: 10px;
width: 100px;
height: 100px;
border: 1px solid black;
}
.rowVert {
padding-top: 40px;
padding-right: 110px;
padding-left: 20%;
}
.vert {
float: left;
margin-left: 14%;
width: 15px;
height: 100px;
}

Related

HTML Canvas align DIV at bottom right-hand corner

I have a Canvas and want to add a Div/Button in the bottom right-hand corner relative to Canvas. My current code looks as follows:
#container {
margin-top: 5px;
width: 96%;
margin: auto;
background-color: blue;
height: 300px;
}
#viewer {
width: 40%;
background-color: red;
height: 100%;
}
#button {
height: 40px;
width: 40px;
background-color: green;
position: absolute;
bottom: 0;
right: 0;
}
canvas {
border: 3px solid black;
width: 100%;
height: 100%;
}
<div id="container">
<div id="viewer">
<canvas></canvas>
<div id="button" onclick="myFunction();"></div>
</div>
</div>
But so far I couldn't manage to find a proper solution for this. It would be great if someone could help me with this.
Is this what you are looking for?
I recommand you checking out this article: CSS Layout - The position Property
#container{
margin-top: 5px;
width: 96%;
margin: auto;
background-color: blue;
height: 300px;
}
#viewer{
width: 40%;
background-color: red;
height: 100%;
position:relative;
}
#button{
height: 40px;
width: 40px;
background-color: green;
position: absolute;
bottom: 0;
right: 0;
}
canvas{
border: 3px solid black;
width: 100%;
height: 100%;
}
<div id="container">
<div id="viewer">
<canvas></canvas>
<div id="button" onclick="myFunction();"></div>
</div>
</div>
I think Temani was right — this puts the button at the bottom right of the canvas, is this not what you wanted?
#container{
margin-top: 5px;
width: 96%;
margin: auto;
background-color: blue;
height: 300px;
}
#viewer{
width: 40%;
background-color: red;
height: 100%;
position: relative;
}
#button{
height: 40px;
width: 40px;
background-color: green;
position: absolute;
bottom: 0;
right: 0;
}
canvas{
border: 3px solid black;
width: 100%;
height: 100%;
}
<div id="container">
<div id="viewer">
<canvas></canvas>
<div id="button" onclick="myFunction();"></div>
</div>
</div>
Like Temani Afif said.
position:relative
on #viewer worked for me.

Align mat-icon and img

I want to align the bottom of my mat icon and that of the img next to it. I've tried multiple things, and this is what it currently looks like:
Here's my HTML:
<div class="container">
<p class="triage"><mat-icon>assignment_ind</mat-icon></p>
<p class="O2"><img src="../../assets/med_O2.png"></p>
</div>
CSS:
.O2, .triage{
display: inline-block;
vertical-align: middle;
}
.container img {
width: 50px;
height: 50px;
}
.container mat-icon{
font-size: 60px;
width: 60px;
}
Use line-height:
.container
{
line-height: 60px; //or what ever height your container is
}
Can you push mat-icon down with a little bit of margin or padding?
.container mat-icon{
font-size: 60px;
width: 60px;
margin-top: 5px;
}
What about something like this?
<style>
.container {
position: relative;
width: 65px;
height: 100px;
}
p.triage {
background: blue;
width: 30px;
height: 40px;
position: absolute;
bottom: 0;
right: 0;
}
p.O2 {
width: 30px;
height: 20px;
background: red;
position: absolute;
bottom: 0;
left: 0;
}
</style>
<div class="container">
<p class="triage"></p>
<p class="O2"></p>
</div>

background-image height to properly scale down in css?

I have currently built a grid layout for my content and i want to use images inside a div column as the background. At first I placed an image with a class of "img-responsive inside the div columns and this works perfectly. Now i want to achieve the same effect but have the image as a background instead. I am having trouble getting my background-image height to scale with the width of the div. With the img-responsive class i have a 'width: 100%;' and 'height: auto;' how do i apply the same logic to a background-image? I can't set the div column class to height: auto; or have a max-height of N pixels because this displays nothing. Below is an example of my code, The top two divs are what what i want my background images to be like. Can anyone explain to me how i can achieve this?
body {
margin: 0 auto;
padding: 30px 30px 5px 30px;
font-family: sans-serif;
color: black;
font-size: 1.2em;
}
section {
width: 80%;
margin: 0px auto;
line-height: 1.5em;
font-size: 0.9em;
padding: 30px;
color: black;
overflow: hidden;
}
.row {
margin: 1% auto;
width: 100%;
overflow: hidden;
padding-bottom: 10px;
}
.row::after {
content: "";
display: table;
clear: both;
}
.col {
line-height: 0;
margin-left: 1%;
margin-right: 1%;
margin-top: 1%;
margin-bottom: 1%;
display: inline-block;
float: left;
overflow: hidden;
}
.col:first-child {
margin-left: 0px;
}
.col:last-child {
margin-right: 0px;
}
.img-responsive {
max-width: 100%;
height: auto;
}
.col.col-6 {
width: 47%;
height: auto;
border: 2px solid black;
margin-left: 1%;
margin-right: 1%;
}
.col.col-6-bg {
width: 47%;
max-height: 1000px;
min-height: 145px;
min-height: 200px;
margin-left: 1%;
margin-right: 1%;
border: 2px solid black;
}
.img-bg {
background-image: url("http://prasinostcharles.com/wp-content/uploads/2014/09/gallery-large_food_cod.jpg");
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
}
#media (max-width: 766px) {
section {
width: 90%;
}
col {
width: 80%;
margin: 10px auto;
padding: 0;
}
.col.col-6 {
width: 98%;
min-height: 141px;
margin-left: 0;
margin-right: 0;
}
.col.col-6-bg {
width: 98%;
min-height: 200px;
margin-left: 1%;
margin-right: 1%;
}
}
<h2>Div with img</h2>
<div class="row">
<div class="col col-6">
<img class="img-responsive" src="http://prasinostcharles.com/wp-content/uploads/2014/09/gallery-large_food_cod.jpg">
</div>
<div class="col col-6">
<img class="img-responsive" src="http://prasinostcharles.com/wp-content/uploads/2014/09/gallery-large_food_cod.jpg">
</div>
</div>
<h2> Div with img as bacground</h2>
<div class="col col-6-bg img-bg"></div>
<div class="col col-6-bg img-bg"></div>

Fluid - horizontally and vertically aligned image relative to its wrapper

In this fiddle, I have an image inside a wrapper in dark-blue, I want it to be 70% horizontally and vertically aligned relative to its wrapper.
I tried to use table-cell and it seems does not work.
HTML:
<div id="menu_content">
<div id="menu_wallet">
<div id="menu_mywallet">
<div id="wallet_logo_new">
<div id="wallet_logo_new_padding">
<img src="https://imagizer.imageshack.us/v2/849x565q90/833/uua2.jpg" id="img_wallet_logo_new" />
</div>
</div>
<div id="wallet_txt">Test</div>
</div>
</div>
</div>
CSS:
#menu_content {
height: 70%;
width: 100%;
position: relative;
border: 0px solid blue;
}
#menu_wallet {
overflow: hidden;
height: 35%;
width: 100%;
display:table;
background-color: #416DB4;
width: 85%;
margin-left: auto;
margin-right: auto;
border-radius: 0.3em;
}
#wallet_logo_new {
display: table-cell;
vertical-align: middle;
width: 50%;
}
#wallet_logo_new_padding {
position: relative;
height: 70%;
width: 70%;
margin: auto;
background-color: #1F58A5;
border-radius: 5px;
display: table;
}
#img_wallet_logo_new {
//margin-top:15px;
width: 20%;
//height: 20%;
//width: 60px;
//height: 60px;
position: relative;
}
#wallet_txt {
display: table-cell;
vertical-align: middle;
font-size: 3em;
color: #FFFFFF;
width: 50%;
}
Is this what you want?
#wallet_logo_new_padding img
{
position: relative;
width: 70%;
margin-left: 15%;
margin-right: 15%;
}

Auto expand DIV with border images

I have a DIV who's borders are made up of images. What I'm trying to do is have this DIV auto expand (in height only) whenever the content does not fit the content area. Otherwise it should just use the min-height. Here is my markup:
XHTML:
<div id="alerts">
<div id="alerts-top"></div>
<div id="alerts-left"></div>
<div id="alerts-content">
<div id="alerts-header">
<p>Alerts</p>
</div>
<div id="alerts-main">
<!-- content in here -->
</div>
</div>
<div id="alerts-right"></div>
<div id="alerts-bottom"></div>
</div>
CSS:
#alerts { float: left; width: 267px; height: 200px; }
#alerts #alerts-top { float: left; background: url(../images/alerts-top.png) no-repeat; height: 12px; min-width: 257px; }
#alerts #alerts-left { float: left; background: url(../images/alerts-left.png) repeat-y; height: 100%; width: 12px; }
#alerts #alerts-content { float: left; min-width: 239px; height: 206px; min-height: 206px; }
#alerts #alerts-content #alerts-header { background: url(../images/alerts-bell.png) no-repeat; height: 20px; width: auto; padding: 10px; }
#alerts #alerts-content #alerts-main { background-color: #FFFFFF; height: auto; }
#alerts #alerts-right { float: left; background: url(../images/alerts-right.png) repeat-y; height: 100%; width: 12px; }
#alerts #alerts-bottom { float: left; background: url(../images/alerts-bottom.png) no-repeat; height: 11px; width: 258px; }
This isn't working for me - there is a gap between the bottom border and the left and right borders. The content area is #alerts-main.
Try this for #alerts-bottom:
#alerts #alerts-bottom {
float: left;
background: url(../images/alerts-bottom.png) no-repeat;
height: 11px;
width: 258px;
margin-top: -9px;
}
With a negative value for margin-top property you control how the div will be displayed (in this case you'll force the #alerts-bottom div to be rendered 9px above the default display).
Hope it helps.
After a "five minutes" consideration I've wrote this code and it will do what you want. Just change the styles to add the images as backgrounds. First the CSS:
#wrapper { position: relative; width: 500px; min-height: 350px; }
#alerts { position: relative; height: 50px; background-color: red; width: 90%; text-align: center; margin: auto; margin-top: 10px; margin-bottom: 10px; }
#top-margin { position: absolute; height: 10px; top: 0; background-color: gray; width: 100%; }
#right-margin { position: absolute; width: 10px; right: 0; background-color: gray; height: 100%; }
#bottom-margin { position: absolute; height: 10px; bottom: 0; background-color: gray; width: 100%; }
#left-margin { position: absolute; width: 10px; left: 0; background-color: gray; height: 100%; }
#content { text-align: justify; padding: 65px 20px 20px 20px; }
And the HTML:
<div id="wrapper">
<div id="top-margin">
<div id="alerts">Alerts alerts alerts</div>
</div>
<div id="right-margin"></div>
<div id="bottom-margin"></div>
<div id="left-margin"></div>
<div id="content">Lorem ipsum dolor sit amet etc...</div>
</div>
The #wrapper's height will expand as more text is added. Sorry that I've changed the names of the Ids and justified the text. But that can easily be remedied.

Resources