Logo Here. | -- 3 Column -- |
Error Message here | |
____________________________________________ || W:232.5px |
| - - 1 Column -- | -- 2nd Column -- || |
| W:232.5px | W:465px || |
|_________________|__________________________||_________________|
Max W: 930px.
Hey, could anyone explain to me how I can achieve this CSS.
3 columns, all has 100% height depending how much contents in the column, e.g. column 1 might be
bigger than column 2 and/or 3.
I've also struggled to keep its structure when minimizing the browser, e.g column 3 is going under column 1.
so if possible I'd like to know how to keep its structure on minimizing.
Something like this maybe...
body {
border:0
}
#logo {
position: fixed;
top: 0px;
left: 0px;
width: 200px;
height: 64px;
background-color: blue;
}
#error-msg {
position: fixed;
top: 0px;
left: 200px;
width: 497px;
height: 64px;
background-color: green;
}
#column1 {
position: fixed;
top: 64px;
left: 0px;
width: 232px;
height: 100%;
background-color: #efefaa;
}
#column2 {
position: fixed;
top: 64px;
left: 233px;
width: 465px;
height: 100%;
background-color: #aaefef;
}
#column3 {
position: fixed;
top: 0px;
left: 698px;
width: 232px;
height: 100%;
background-color: #efaaef;
}
<div id="logo"></div>
<div id="error-msg"></div>
<div id="column1"></div>
<div id="column2"></div>
<div id="column3"></div>
To prevent column 3 go under column 1 either wrap everything inside a container with fixed width or use % as unit for the columns
I would go with a Flexbox with align-items: flex-end;
That will align the items to the bottom of the container and respect their variable height and width.
Here is a great reference for flexboxes
What you're looking for is pretty straight forward, you just need to add a wrapper to the first two columns and use that as the 'main' column.
In terms of responsiveness the best method is converting your pixels to percentage values, then using breakpoints when the widths start to become too tight/too wide.
|________________________________________________| | --Side Column-- |
| - - Main Column - - | | |
| W: 75% | | |
|________________________________________________| | |
| Logo Here. | | |
|________________________________________________| | |
| Error Message here | | |
|________________________________________________| | |
| ______________________________________________ | | W:25% |
| | - - 1 Column -- | -- 2nd Column -- | | | |
| | W:33.3% | W:66.6% | | | |
| |_________________|__________________________| | |_________________|
| |
------------------------------------------------
Related
I am having a hard time with css. I have a content that content class a image and a text. I would like to align the text to the right side of the screen but I do not want to limit the image to the width of the content. I would like to allow the image go outside.
I tried to play with positions and "fixed" allow me to move the image outside of the content by the content height changes de-coupling the image.
<div class="content2">
<img id="cloudimg" src=".\Cloud.jpg">
<p>Cloud Computing</p>
</div>
and in my css
.parallax-wrapper-cloud {
width: 460px;
height:180vh;
position: absolute;
right:0;
padding-top:20vh;
box-sizing: border-box;
transform-style: preserve-3d;
}
.parallax-wrapper-cloud::before {
content:"";
width: 100vh;
height: 100vh;
top:0;
right:0;
background-color: #ffddfbff;
!background-image: url("./bkg4.jpg");
!background-repeat: no-repeat;
!background-position: left;
position: absolute;
z-index: 2;
transform:translateZ(-1px) scale(2);
}
.content2 {
margin: 0 auto;
color: #black;
padding: 50px;
width: 100;
background: #ee0d0d;
}
this is what I see (right side the image is truncated):
----------------------
| |
| --------------- |
| | half | |
| | image | |
| | | |
| --------------- |
| Cloud Computing |
| |
----------------------
this is what I would like to see (image full displayed and partially outside):
----------------------
| |
--------------- |
| full | |
| image | |
| | |
--------------- |
| Cloud Computing |
| |
----------------------
as described above
.content2 {
margin: 0 auto;
color: #black;
padding: 50px;
width: 300px;
background: #ee0d0d;
text-align: center;
}
#cloudimg {
height: 100%;
width: 100%;
left: 40%;
transform: translate(-40%);
}
<div class="content2">
<img id="cloudimg" src="https://i1.wp.com/amergin.net.au/wp-content/uploads/2017/03/image-placeholder.jpg?ssl=1">
<p>Cloud Computing</p>
</div>
If you are just trying to move the image a bit to the left without messing up the general flow of your site, you might want to use transform: translateX(-100px);. The -100px should be replaced by the amount of pixels (or cm/in/pt/pc/em/...) you want the image to be moved.
What this does is that it takes the object and just moves it, without affecting the document flow. That means that the other object will position themselfs as if the object wasn't moved at all, because this transformation happens after everything is positioned.
If you want to read more, I recommend reading this article on w3school or to look at the translate specification here on the MDN web docs.
Note that you can also use a percentage like transform: translateX(-50%);, but the percentage is relative to the object itself, so -50% will move an 1000px wide object 500px to the left.
In your case, I would recommend something like
#cloudimg {
transform: translateX(-20%);
}
I have a problem with sizing a scrolling div to fill the window, considering that I have one or more top divs and a footer div.
this is what I need
+------------------+ +------------------+ +------------------+
| top1 | | top1 | | top1 |
+------------------+ +------------------+ +------------------+
| top2 | | top2 | | |^|
| | +------------------+ | | |
+------------------+ | |^| | | |
| |^| | | | | scroll | |
| | | => | scroll | | => | | |
| scroll | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| |v| | |v| | |v|
+------------------+ +------------------+ +------------------+
| footer | | footer | | footer |
+------------------+ +------------------+ +------------------+
Top1 has a fixed height.
Footer has a fixed height.
Top2 doesn't have a fixed height and sometimes doesn't even appear.
The only way I know to do that is by defining the container height, fixing its top and its bottom. But I cannot fix the top property since the top2 div has variable height...
Can someone help me?
html:
<body>
<div id='top1'>Top1</div>
<div id='top2'>Top2</div>
<div id='container'>
<ul id='data'>
<li>item1</li>
<li>item2</li>
<li>item3</li>
<li>item4</li>
<li>item5</li>
<li>item6</li>
<li>item7</li>
<li>item8</li>
<li>item9</li>
<li>item10</li>
</ul>
</div>
<div id="footer">footer</div>
</body>
css:
body, html {
height: 100%;
}
#top1 {
width: 100%;
height: 50px;
background-color: #EEE;
text-align: center;
line-height: 50px;
}
#top2 {
width: 100%;
height: 50px;
background-color: #DDD;
text-align: center;
line-height: 50px;
}
#footer {
width: 100%;
height: 50px;
background-color: #BBB;
text-align: center;
line-height: 50px;
position: fixed;
bottom: 0;
}
#container {
overflow: auto;
width: 100%;
position: absolute;
top: 100px;
bottom: 50px;
}
#data li {
font-size: 30px;
padding: 10px;
}
try it
first get windows height by this function
$( window ).height();
and make one more function for top2
$( document ).height();
pluse heights 1st header + 2nd footer +.3rd top2 ( get by this function $( document ).height();)
minus height in windows height
then will get new height and apply on scrlloing div
one more thing for make better scrlloing use resizing function
I have 3 divs with display:inline-block style. I want to set their height value so that it matches the one with the highest value. I also want to set height values auto. I've tried to show visually what I want to get below. Is this possible with pure CSS?
----- ----- ----- ----- ----- -----
| | | | | | | | | | | |
----- | | | | ==> | | | | | |
----- | | | | | | | |
----- ----- ----- -----
With CSS you can set the inner divs to be display: table-cell and the outer one to be display: table
Demo: http://jsfiddle.net/maniator/C2dNu/
HTML:
<div id='out'>
<div class='red'></div>
<div class='blue'></div>
<div class='green'></div>
</div>
CSS:
.red {
background: red;
height: 60px;
}
.blue {
background: blue;
height: 160px;
}
.green {
background: green;
height: 80px;
}
#out {
display: table;
width: 500px;
}
#out > div {
display: table-cell;
width: 33%;
}
With JS, it can be done with Equalize.js. I don't know a pure CSS solution though.
If I have two divs, outer and inner, with following stylesheet:
#html,body{
height:100%;
margin:0;
padding: 0;
}
#outer{
position: relative;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: red;
}
#inner{
position: relative;
top: 0;
left: 0;
width: 0;
height: 100%;
background-color: yellow;
}
At the same time, outer and inner div should grow both in width and height if content inside innerdiv grows dynamically.
+---------------------+
| +=================+ |
| | | |
| | | |
| | | |
| | | |
| | div id="inner" | | div id="outer"
| | | |
| | | |
| | | |
| +-----------------+ |
+---------------------+
But if I change the stylesheet to this:
#html,body{
height:100%;
margin:0;
padding: 0;
}
#outer{
position: relative;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: red;
}
#inner{
position: relative;
top: 50px;
left: 0;
width: 0;
height: 100%;
background-color: yellow;
}
The inner div will go down to 50px from top and bottom of outer div as there is top:50px style on inner div like this:
+---------------------+
| |
| +=================+ |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
+-| |-+
| |
+-----------------+
But I want inner div will go down 50px from outer div, but remain bottom of outer div with position: relative like this:
+---------------------+
| |
| +=================+ |
| | | |
| | | |
| | | |
| | | |
| | | |
| +-----------------+ |
+---------------------+
How to do this?
You can achieve this using a jQuery
var newinnerdivheight=$("#innerdiv").height() + $("#innerdiv").innerHeight() +$("#innerdiv").outerHeight();
$("#innerdiv").height(newinnerdivheight);
$("#outerdiv").height(newinnerdivheight+50);
similarly for width also...
The basic question is: How can a be shrink-to-fit over an element while itself containing other elements?
The goal is to have a (centered) menu over an (centered) image, which´s width and height shall relate to the images dimensions.
All of it being responsive, meaning no absolute sizes!
Here´s the sample code:
<div id="menu">
<img src="picture.jpg" />
<div id="left">
test1
</div>
<div id="right">
test2
</div>
</div>
#menu{
position:relative;
display: table; /*tried inline-block as well */
text-align: center;
line-height: 1;
}
#menu img{
height: 90%;
position:relative;
}
#left{
width: 46%;
background-color: #ffcdcc;
float: left;
text-align: right;
}
#clear{
clear: both;
}
#right{
width: 46%;
background-color: #324344;
float: right;
text-align: left;
}
and this is what it´s supposed to look like:
____________________________________
| |
| ------------------------------ |
| | | |
| | p i c t u r e | |
| | | |
| | | |
| | | |
| | | |
| | left <button> right | |
| | | |
| ------------------------------ |
| |
------------------------------------
The height/width ratio of the picture is always the same. It´s total size depends on the users window though.
I just can´t get the "menu" div to wrap around the and the "left" and "right" divs be positionable at the same time.
Is this even possible? I´m not even talking about browser compatibiliy yet...
See if this works: http://jsfiddle.net/sdvnh/1/
Changes:
#menu {
display: block;
}
#menu img{
height: 90%;
width: 90%;
}