I'm trying to figure out a way to have a certain amount of space between the top of my footer and a div.
Right now each page is of a different size and I'm adjusting this manually. The biggest issues I'm having is across different formats of web browsers my manual space is changing. and on a couple pages I have a js questionnaire, when the questionnaire is completed my div slides down over top of my back and next buttons. I corrected this by creating a new CSS style for it.
Is there a way I can set my div (Which is a box with text) to align on every page the same distance from the footer and on every browser. Right now my code is only working correctly in IE9.
Here is the CSS I'm using:
#mainInfoBox
{
margin-bottom:-35px; !important;
clear:both;
min-height:2em;
height: auto !important;
height:32px;
padding: 2px 3px 0 3px;
border: 1px solid #4c6352;
background-color:#f2f684;
color:#000;
font-family:Tahoma, Geneva, sans-serif;
text-align:center;
display:block;
position: relative;
}
And this is what I'm using in the html, though that values change on every page:
<div id="mainInfoBox" style="margin-top:193px; clear:both">Blah Blah Blah</div>
Assuming your footer is the same on every page, you can set a fixed height, or at least calculate the height of it. Then absolutely position the div you want on top of it using the bottom property like so:
footer { height: 250px; }
#mainInfoBox {
position: absolute;
bottom: 260px; /* so it is 10px on top of the footer */
}
Related
I'm trying to avoid the margin of the first page. All tables (there are many) are fitting a page. But the first one has a margin.
I tried: so many ways. Is there a way with CSS to avoid margin on first page? I tried on body, html, page...
I've searching a lot. But I can't find a solution. I though of creating an element and put it on the first page.
My page has many tables. One per page. Except the first one fits on one page due to the margin.
#media print {
#page {
margin: 0mm;
size: auto;
padding: 0;
}
#page:first {
margin: 0px;
color:blue;
}
html {
margin: 0px;
}
body {
display: table;
margin: 0mm 0mm 0mm 0mm; /* margin you want for the content */
margin-top:0px !important;
}
.tableSchedule tr {
padding-top: 0px;
height:45px;
}
.tableSchedule {
table-layout:fixed;
width:1130px;
margin:0;
page-break-after:always;
}
I had a similar problem with images and divs in the past. Turns out that even if you set the margin to 0 some browsers will seperate elements, particularly inline elements, with a space of 1 em. Setting the font-size: 0 for the parent element removed that "phantom" margin. Just don't forget to change the font size back for the child elements!
Alternatively you can style the first table with a negative margin to cheat. i.e. margin-left: -15px . Or so depending on your needs.
I am using bootstrap-treeview to try to make a nice treeview within my MVC project. This control is available on NuGet so its easy to get started with it. The left hand div shows the tree and the right hand div shows the content of each element when clicked:
<body>
<div id="tree" style="position:absolute; width: 20%; height: 100%; overflow: scroll"></div>
<div id="content" class="list-group-item node-tree" style="position: absolute; left: 20%; width: 80%; height: 100%">This is where content goes once you click on a file or folder element.</div>
</body>
There is a slight problem, though. The content of the div with the ID = tree gets cut off:
Ideally, I would like these list elements to overflow to the right, beyond the size of the div with the ID = tree, as you can tell, because I have set overflow: scroll, so I do not want any text to wrap to a new line.
On runtime, it appends list elements as follows...
These list elements seem to have the following CSS:
.list-group-item {
position: relative;
display: block;
padding: 10px 15px;
margin-bottom: -1px;
background-color: #fff;
border: 1px solid #ddd;
}
I have tried adding white-space: nowrap; to this CSS, which makes the text do what I want (and overflow with a scrollbar), but the background and border of each list element stay at the width of the parent (which is not what I want; I want them to also overflow all scrollable width just like I did with the text)!
What can I do to make each element of this list properly overflow past the bounds of the parent div they all exist under?
Edit: I've tried putting overflow:visible on all parent levels as well, but it did not work. It removed the vertical scroll bar and kept all list item background borders still restricted to the width of the tree div. I also found that setting width = 10000px on the .list-group-item CSS partially gives me what I want as well, but obviously this makes the backgrounds too wide and the scroll bar becomes too elongated. I want the width of all list elements to be equal to the width of the widest overflowing content.
I figured it out. I had to change the display to table-row-group and I had to add white-space: nowrap:
.list-group-item {
position: relative;
display: table-row-group;
padding: 10px 15px;
margin-bottom: -1px;
background-color: #fff;
border: 1px solid #ddd;
white-space: nowrap;
}
Add overflow:visible to the parent element(s). You may need this at multiple levels, as each parent element could potentially restrict the content.
I am adding footer section to a simple web page since page has only few items on the page show white space at the bottom of the footer if i keep footer height at 150px. When i keep height:100% to take the rest of the space at bottom of the page, Rather it adds 3 - 4 times more to the footer section which show vertical scrollbar.
Is their a way i can only add that much height to footer section so that scrollbar wont be added. even using jQuery.
Example : http://jsfiddle.net/57fBK/10/
In the above mention fiddle example your will notice footer height than usual. To me it seems it by default always take height of HTML elements defined above the footer section.
.fullWidth {
width: 100%;
margin-left: auto;
margin-right: auto;
max-width: initial;
background-color:red;
height:100%;
}
.footer
{
margin-top:50px;
text-align:center;
}
The problem here is that giving height:100% to .fullWidth makes it 100% of the viewport height...which means, if there's any content above it that pushes it down, .fullWidth is going to extend that much below the bottom of the viewport, creating a scrollbar. If you're only looking to visually have the footer appear to fill the remaining space (between the content and the bottom of the viewport), here's a way I've used once to fake it.
Simply make the entire body the same background colour as the footer, and place the rest of the content in a wrapper with the main background colour. For example, your HTML might become:
<div class="main">
(Content from before goes in here.)
</div>
<div class="row">
<div class="large-12 columns footer">footer</div>
</div>
And some altered/added CSS (it should be noted that .fullWidth is rendered completely unnecessary by this approach, so you can remove it from your HTML/CSS):
body{
background-color:red; /* Footer background colour */
}
.main{
background-color:#FFF; /* Main background colour */
}
.footer {
background-color:red;
margin-top:50px;
text-align:center;
}
Here's a JSFiddle demonstrating how this looks. Now, if there's extra space below the footer, it won't be perceivable unless you start inspecting elements. If this isn't what you wanted, you may want to look into sticky footers, as others have suggested.
Hope this helps! Let me know if you have any questions.
try this:
.fullWidth {
width: 100%;
margin:0 auto;
max-width: initial;
background-color:red;
height:100%;
}
also you need to set height for footer:
.footer
{
margin-top:50px;
text-align:center;
height: 50px;
}
I'm making a navigation system on some of the pages of my website that is roughly like this:
<span>Page</span>
Where each navigation link would look like that. I want the link representing current page
to have the following properties:
background-color: buttonface; border: 2px solid grey; border-radius: 5px;
and all navigation links to have these properties:
padding: 0 6px 0 6px;
In addition I wanted to make the border and background of the current page's link fade into any link on .mouseenter() and fade out on .mouseleave() unless it is the current page in which case it should not fade out. I am relatively new to jQuery and I have no idea how to do this.
It isn't completely necessary for the links to be in the format I put above as long as they're listed horizontally across the page and have the properties I specified. If it matters my site also uses the following code for style already:
body{font-family: 'Raleway'; background: #F07400; color: black; font-size: 18px; margin: 20px 0 20px 20px;}
button{font-size: 18px; font-family: 'Raleway'; border-radius: 5px; border: 2px solid grey;}
and
$(document).ready(function() {
widthval = $(window).width()-40;
$("body").css("width", widthval);
$("body").fadeOut(0);
$("body").fadeIn(1600);
$(window).resize(function(){
widthval = $(window).width()-40;
$("body").css("width", widthval);
});
});
You could layer two body layers, by placing a body2 positioned absolute as a child element of body, which would draw it ontop of body. Have the body 2 contain the border information and body contain the content. Then fade body2.
But this solution would require the content to exist in both body and body2 because clicks would be blocked to body and processed through body2.
updated
<div style="width:needed; height:needed;">
<div2 style="position:absolute; width:sameAsBody; height:sameasbody" class="fade">
this content will fade.
</div2>
content content here will be faded to. If changing just the background it would be literially the same hence it appears that the content did not fade.
</div>
$(document).ready(function(){
$(‘.fade’).fadeTo(2000, 1.0).fadeTo(4000, 0.0);
});
I have a complex HTML application, so unfortunately cannot really provide a code sample. We are trying to get the div (highlighted in red) to fill the remaining vertical space (see image).
The application consists of a header (in black), a sidebar on the left which can be dismissed or resized (note: the horizontal components resize correctly). To the right of the sidebar is another div (mainDiv). mainDiv contains a div at the top for the controls, and a div underneath it for the table of data (highlighted in red).
This table can potentially contain lots of data, so it needs its own scrollbar if the data doesn't fit on the screen.
We just want the table to fill all of the available horizontal and vertical space. We just can't seem to make it work.
We have created a jsfiddle example to demonstrate our layout as best we can. This can be seen here. We just want this div (in jsfiddle the div is called "tablewrap") to take up all of the remaining space.
Code (from jsfiddle) is as follows:
html
<div class="header">Header</div>
<div class="sidebar">This is the sidebar</div>
<div class="tablewrapper">
<div class="tableheader-controls-etc"></div>
<div class="tablewrap">table</div>
</div>
css
.header { height: 50px; background:black; color:white; }
.sidebar { height:100%; position:fixed; width 200px; background:gray; color:white; }
.tablewrapper{ float:right; width:75%; border:1px solid; margin-top:30px; margin-right:30px;}
.tableheader-controls-etc { height:150px; background:blue; color:white; }
.tablewrap { height: 200px; border: 2px solid red; width:100%; overflow:auto;}
If anyone can provide a solution that would be great. We would prefer CSS but can cope with Javascript.
Thanks,
Phil
The trick is to set position: absolute, then adjust the top, bottom, left and right properties as needed. See fiddle and explanation.
.tablewrap {
position: absolute;
top: 240px;
bottom: 0;
left: 150px;
right: 40px;
height: auto;
width: auto;
...
}
You can try this:
.tablewrap { height: 200px; border: 2px solid red; width:100%; overflow:auto; min-height:300px}
(Set the min-height as you want)
Well, it's time to say what you probably don't want to hear hehe: you can't do this with CSS.
You have to use javascript in order to find out two things:
Viewport height
Controls div height
Once you know those two heights, you can set your table height to:
finalHeight = viewport - (controls+header+footer)
If header and footer have also dynamic heights, use javascript to calculate them.
You will also need to recalculate this height on window resize. And of course your layout won't work if javascript is disabled.