How to make a div full height of remaining space on screen - html

I've recently published my new website but on larger resolution monitors my 2nd content div which comes under my navigation and a small piece of text only expands to the size of the content within it which is fine except from one page where there is very little content meaning there is a large white section between it and the page footer.
Here's a demo: http://jsfiddle.net/XUuVL/
I was wondering how I could make it so that the grey area would fill that whitespace left underneath it.
Cheers.
html,body
{
background: #FFFFFF;
font: 0.74em Arial;
height: 100%;
}
#wrapper
{
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto 0;
}
#content
{
width: 90%;
min-width: 1000px;
height: 100%;
padding: 20px 5% 20px 5%;
padding-bottom: 30px;
margin-left: auto;
margin-right: auto;
}
#content2
{
width: 90%;
min-width: 1000px;
height: auto;
min-height: 100%;
padding: 60px 5% 20px 5%;
background: #808080;
overflow: hidden;
}

In this case, since body and #wrapper have 100% height, you cannot give height in percentage to children elements. It would work if you give fixed height i.e. height in percentage to #wrapper.
You can give gray color to body and give white color to #content.

Check this out: http://jsfiddle.net/XUuVL/2/
.
Using position: absolute; and bottom: 0; solving your problem

You can give the wrapper element the same background and the bottom box-shadow as content2. Then it will look like content2 extends to the bottom. You must also give it the same width
#wrapper {
width: 90%;
min-width: 1000px;
background: #808080;
-moz-box-shadow: inset 0 -8px 8px -8px #000000;
-webkit-box-shadow: inset 0 -8px 8px -8px #000000;
box-shadow: inset 0 -8px 8px -8px #000000;
}
Now you remove the bottom box-shadow from content2 and give a white background to the content element
#content {
background: #FFFFFF;
}
#content2 {
-moz-box-shadow: inset 0 8px 8px -8px #000000;
-webkit-box-shadow: inset 0 8px 8px -8px #000000;
box-shadow: inset 0 8px 8px -8px #000000;
}
See modified JSFiddle

add position: absolute in your content2 ... i hope you will want like this...
#content2
{
position:absolute;
width: 90%;
min-width: 1000px;
height: auto;
min-height: 100%;
padding: 60px 5% 20px 5%;
background: #808080;
overflow: hidden;
}

Related

Playing with CSS shapes: How to make a custom ICON using pure HTML and CSS

Currently, I am playing with HTML and CSS and I wanted to make a icon from this image
the image is somewhat like that. I tried adding different shapes of ovals and circles inside the bigger circle but it did not work. For the shaded part, I used a box-shadow in styling it. There are already too many divs in my sample icon. I just want to have it simple and readable.
Here is my HTML structure:
<link rel="stylesheet" href="style.css">
<div class="cont">
<div class="icon2">
<div class="inner-circle"></div>
</div>
</div>
and here is my CSS:
.cont {
width: 190px;
height: 190px;
padding: 20px;
}
.icon2 {
position: relative;
border: 2px solid #353332;
width: 187px;
height: 184px;
border-radius: 50%;
background-color: #fff;
box-shadow: inset 20px 35px #1CAEE3;
transform: rotate(177deg);
}
.inner-circle {
border: 7px solid #353332;
width: 120px;
height: 183px;
background-color: #fff;
border-radius: 50% 50% 50% 49% / 60% 52% 40% 40%;
transform: rotate(240deg);
display: block;
margin: 6px 0px 4px 35px;
border-top: 0;
border-bottom: 0;
border-left: 0;
}
Can you explain me this and how can I come up with a solution to my problem? I'm stuck for hours and I just wanted to try it with pure HTML and CSS and not using photoshop.
You can easily do this with one element and radial-gradient. Simply adjust the percentage used inside the gradient to control the shape:
.box {
width:150px;
height:150px;
border-radius:50%;
border:4px solid;
background:
radial-gradient(circle at top left,transparent 59.4%,black 60% calc(60% + 4px),orange calc(60% + 5px));
}
<div class="box"></div>
You can also use box-shadow ;)
https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow
The box-shadow CSS property adds shadow effects around an element's frame. You can set multiple effects separated by commas. A box shadow is described by X and Y offsets relative to the element, blur and spread radii, and color.
demo aside your image:
div {
border: solid 6px;
display: inline-flex;
height: 200px;
width: 200px;
border-radius: 50%;
box-shadow: inset -50px -70px 1px -30px rgb(255, 127, 39), inset -56px -77px 1px -33px;
}
code {
font-size: 30px;
color: green;
margin: auto;
font-weight: bold;
}
div,
img {
vertical-align: middle;
}
<img src="https://i.stack.imgur.com/HRpQY.png">
<div><code>box-shadow</code></div>
another example :
div {
float:left;
height: 180px;
width: 180px;
margin: 1em;
box-sizing: border-box;
padding: 25px;
background: #F4E5D9;
box-shadow: inset -40px -40px 3px -20px #C5824D, inset 40px 40px 3px -20px #EABD9A, inset 0 0 2px 30px #AD6026, inset 0 0 0px 32px #705642, inset 0 -55px 3px 10px #705B4B, inset 0 55px 3px 10px #705B4B, 0 0 3px 2px #705B4B, 0 0 3px 4px #665447, 0 0 3px 7px #3F332A, 0 0 3px 9px #705642, 88px 90px 1px -86px gray, 87px 85px 2px -82px #F2C232, 85px 95px 2px -82px #A30700, 92px 92px 2px -82px #C5824D, 88px 90px 10px -70px white;
border-radius:50%;
display:flex;
flex-direction:column;
justify-content:center;text-align:center;
}
div + div {border-radius:4em /50%;
<div>
<p>inset shadow </p>
<p>border-radius </p>
<p>decreased shadow </p>
</div>
<div>
<p>inset shadow </p>
<p>border-radius </p>
<p>decreased shadow </p>
</div>
you may also draw citrus slices https://codepen.io/gcyrillus/pen/wutEK .
but SVG would be at best here ;)
You could make use of a pseudo element and have an overflow:hidden to hide the rest of the pseudo element's parts that fall outside of the div's 'outer circle'
div {
height: 200px;
width: 200px;
overflow: hidden;
border: 5px solid black;
background:orange;
border-radius: 50%;
position: relative;
}
div:after {
content: "";
position: absolute;
height: 100%;
width: 200%;
border: inherit;
border-radius: 50%;
background: white;
top: -20%;
left: -100%;
}
<div></div>

Make body width correspond to divs existence

I created a horizontal timeline with dots for each information, however if enough "dots/information" are created the body width needs to be able to expand to make the dots continue on the same line of the timeline instead of moving down a line because of the limited width of the page.
I tried giving the body a larger width, it does fix the problem but I would much rather have the width working dynamically to correspond with the timeline's dots. So if there is only a few dots on the timeline, the page wont have to be any wider, but if there is a lot then the page width should expand.
Here is the css of my timeline.
The time is implemented with PHP and HTML. The dots are created through a simple php sql loop.
div#timeline3 {
background-color: lightblue;
margin-top: 150px;
height: 12px;
width: 100%;
top: 0px;
position: relative;
}
div#timeline3 .inside {
position: absolute;
height: 4px;
background-color: #fff;
width: 0%;
top: 3px;
left: 0;
}
div#timeline3 .dot {
z-index: 99;
transition: 0.3s ease-in-out;
width: 52px;
height: 52px;
border-radius: 50%;
position: relative;
top: -20px;
margin-left: 220px;
float: left;
text-align: center;
cursor: pointer;
-webkit-box-shadow: 8px 0px 05.3px -8px black, -8px 0px 05.3px -8px black;
-moz-box-shadow: 8px 0px 05.3px -8px black, -8px 0px 05.3px -8px black;
box-shadow: 8px 0px 05.3px -8px black, -8px 0px 05.3px -8px black;
}
div#timeline3 .dot:nth-child(1) {
left: 1%;
background-color: lightblue;
}

Push top half of image outside of card

I am attempting to create the following design in Ionic:
Currently, I am specifically trying to push the top half of an image past the top of the card and have the image be about 80% of the width of the card.
How can I push the top half of the image outside of the card?
I have created a StackBlitz for this issue.
Edit: I have been able to make the image protrude the top half of the card but the image is overlapping text and other images. How can I push the card down where the top half contains the bottom half of the image and the bottom half contains the additional text, images, etc.?
Here is my CSS:
.card {
margin-left: 30px;
margin-right: 30px;
width: auto;
border-radius: 8px;
position: relative;
display: block;
margin-top: 100px;
overflow: visible;
div {
position: absolute;
top: -95px;
width: 100%;
text-align: center;
}
img:not(.castImg) {
width: 80%;
border-radius: 8px;
-webkit-box-shadow: 0 8px 6px -6px black;
-moz-box-shadow: 0 8px 6px -6px black;
box-shadow: 0 8px 6px -6px black;
display: block;
margin: -100px auto 0;
}
}
looking at the code here Made 2 changes in the home.scss file... play around with 17% which is an arbitrary number on both places
.card {
margin-left: 30px;
margin-right: 30px;
width: auto;
border-radius: 8px;
margin-top: 17%; /* Change 1a */
overflow: visible; /* Change 1b */
img:not(.castImg) {
width: 80%;
margin: auto;
margin-top: -17%; /* Change 2 */
border-radius: 8px;
-webkit-box-shadow: 0 8px 6px -6px black;
-moz-box-shadow: 0 8px 6px -6px black;
box-shadow: 0 8px 6px -6px black;
}
ion-card-title {
font-weight: bold;
text-align: center;
}
}

stick div position as it is

Hello i have a problem with my styling have two divs witch height is auto for both but the thing is when the first div (.filter) height is changed the second div (.posts) goes down as much as height was changed (.filter height +50 , .post down +50px):
my css :
.fp {
position: relative;
width: 1050px;
height: auto;
background-color: red;
left: 170px;
}
.filter {
background-color: white;
position: relative;
width: 250px;
min-height: 300px;
height: auto;
top: 20px;
border-radius: 4px;
border: 1px solid #1a171a;
-webkit-box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.6);
-moz-box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.6);
box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.6);
}
.posts {
background-color: white;
position: relative;
width: 750px;
height: auto;
float: right;
margin-top: -280px;
border-radius: 4px;
border: 1px solid #1a171a;
-webkit-box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.6);
-moz-box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.6);
box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.6);
}
html :
<div class="fp">
<div class="filter">
</div>
<div class="posts">
</div>
</div>
Always prefer display: inline-block instead float. Floating breaks the normal flow of elements. Also, negative margin isn't a good practice. The declarations position: relative or position: absolute should be used only on specific cases, not to align all blocks.
https://jsfiddle.net/alexndreazevedo/vg9bajrL/
Add float: left to .filter, erase the negative margin-top from .posts and add overflow: hidden to .fp to have the container really covering both elements.
After all the comments, I've set up a complete solution for you here: http://codepen.io/anon/pen/ZWNXEN
It adds margins where necessary or desireable, defines both elements as float (left/right) and lets the container cover the child elements (overflow: hidden). Apart from that I removed position: relative, which is of no use in this context.

Center a div within a div and make the outter div autosize according to inner div

Right now I can either auto-size the container div to the inner div or I can center the whole thing... but I can't figure out how to do both at the same time.
Below is the CSS/Layout as I have it. Right now both the page and main elements are centered but if the content is beyond a certain size it goes over the borders without either element re-sizing.
LAYOUT
</head>
<body>
#using Monet.Common
<div id="contentContainer">
<div class="page">
#Html.Partial("NavBarPartial")
<section id="main">
<div id="content">
#RenderBody()
</div>
<div id="footer">
<span style="color: Gray;"> </span>
</div>
</section>
</div>
</div>
</body>
</html>
CSS
#contentContainer {
width: 100%;
}
.page
{
width: 50%; /*1030px;/*75em;/*83.7em;*/
margin-left: auto;
margin-right: auto;
}
#content {
padding: 20px;
}
#main
{
width:auto;
display:block;
height: auto;
background-color: white;
/*border: 1px solid #999;*/
border-radius: 5px 10px / 10px;
-webkit-box-shadow: -3px 10px 62px -18px rgba(10,9,10,0.75);
-moz-box-shadow: -3px 10px 62px -18px rgba(10,9,10,0.75);
box-shadow: -3px 10px 62px -18px rgba(10,9,10,0.75);
}
footer,
#footer
{
/*background-image: url('Images/TEST2body_bot.png');*/
background-color: #fff;
background-repeat: no-repeat;
color: #999;
padding: 10px 0;
text-align: center;
line-height: normal;
margin: 0 0 30px 0;
font-size: .9em;
border-radius: 0 0 4px 4px;
-webkit-border-radius: 0 0 4px 4px;
-moz-border-radius: 0 0 4px 4px;
}
EDIT
The problem I'm having is best illustrated w/two examples. In one instance I have a table that is 1030px wide. This table is left-justified perfectly but the right edge of the table flows well beyond the right border of the main element.
Another problem is with a set of radio buttons. When the page loads there is supposed to be nothing but white space to the right of the buttons. A specific menu appears to the right of the radio buttons based on the user's selection. When the page loads it looks like there's just enough space for the menus, however they are loading UNDERNEATH the radio buttons instead of to their right.
SECOND EDIT
This is the CSS that allows me to auto-size the div, however everything is left justified (commented out certain sections and added display: inline-block and overflow: auto to .page).
/*#contentContainer { Had to comment this whole section out
width: 100%;
}*/
.page
{
/*width: 50%; /*1030px;/*75em;/*83.7em; Needed to comment this attribute as well*/
display: inline-block;
overflow: auto;
margin-left: auto;
margin-right: auto;
}
#main
{
height: auto;
display:block;
height: auto;
background-color: white;
/*border: 1px solid #999;*/
border-radius: 5px 10px / 10px;
-webkit-box-shadow: -3px 10px 62px -18px rgba(10,9,10,0.75);
-moz-box-shadow: -3px 10px 62px -18px rgba(10,9,10,0.75);
box-shadow: -3px 10px 62px -18px rgba(10,9,10,0.75);
}
You need to set the parent element to
display: table-cell;
vertical-align: middle;
text-align: center;
#and some kind of height:
height: 350px;
The #page-div to:
display: inline-block;
Like this:
http://jsfiddle.net/YA2Ns/1/
Don't ask me why, but changing adding display:table and margin: 0 auto to the .page element worked. I actually no longer need the contentContainer div anymore. Here's the final product.
CSS
.page
{
display: inline-block;
overflow: auto;
display: table;
margin: 0 auto;
}
#main
{
height: auto;
display:block;
height: auto;
background-color: white;
/*border: 1px solid #999;*/
border-radius: 5px 10px / 10px;
-webkit-box-shadow: -3px 10px 62px -18px rgba(10,9,10,0.75);
-moz-box-shadow: -3px 10px 62px -18px rgba(10,9,10,0.75);
box-shadow: -3px 10px 62px -18px rgba(10,9,10,0.75);
}
#content {
padding: 20px;
}
footer,
#footer
{
/*background-image: url('Images/TEST2body_bot.png');*/
/*background-color: #fff; */
background-repeat: no-repeat;
color: #999;
padding: 10px 0;
text-align: center;
line-height: normal;
margin: 0 0 30px 0;
font-size: .9em;
border-radius: 0 0 4px 4px;
-webkit-border-radius: 0 0 4px 4px;
-moz-border-radius: 0 0 4px 4px;
}
LAYOUT
<body>
#using Monet.Common
<div class="page">
#Html.Partial("NavBarPartial")
<section id="main">
<div id="content">
#RenderBody()
</div>
</section>
</div>
<div id="footer">
<span style="color: Gray;"></span>
</div>
</body>