First here is the screenshot of what is wrong with the current code
and here is the code that is associated with the same
<nav class="blue darken-3">
<div class="nav-wrapper">
Chatter
<ul class="right hide-on-med-and-down">
<li><a nohref><i class="material-icons">search</i></a></li>
<li><a nohref><i class="material-icons">view_module</i></a></li>
<li><a nohref><i class="material-icons">refresh</i></a></li>
<li><a nohref><i class="material-icons">more_vert</i></a></li>
</ul>
</div>
</nav>
<div class="row">
<div class="col s3 red">1</div>
<div class="col s9 indigo" style="height:100%">4</div>
</div>
first i don't see the reason why 4 is a little below 1. This bug resolves when i add a margin of 10 px to top of row, but the thing is that red menu bar should be colored and therefore i don't wan't any white space in between that.
The second question, that i am not sure about how to do that the correct way is that i want both blue and red to cover the entire height on the browser window. Is there anyway how to do the same in materialize , or if not please help me with how that is possible.
To set the height to full view add this CSS
.col.s3.red, .col.s9.indigo {
min-height: 100vh; /* use "vh" instead of % */
}
It will help setting the height to view port height.
These solutions work so long as the content in either of the div's does not overflow the browser window and cause it to scroll.
In order for both columns to fill 100% of the page height (not viewport height) I found this:
CSS: equal height columns
Add the following code to the parent div (row)
.flex {
display: flex;
flex-wrap: wrap;
min-height: 100vh; /*or use calc(100vh - header_height)*/
}
I solved this using:
.full-width {
height: 100%;
min-height: 1000px !important;
}
You need to use !important because .row .col has a min-height: 1px;
<div class="col s3 yellow lighten-4 full-width">
A
</div>
<div class="col s9 grey lighten-4 full-width">
B
</div>
This solution used 100% of the viewport's larger dimension.
.myColumnFormat {
min-height: 100vmax;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" rel="stylesheet" />
<div>
<h4>This solution uses Materialize</h4>
</div>
<div class="row">
<div class='col myColumnFormat blue s6'>
<ul>
<li>This column is blue</li>
<li>This column's background colour is full length</li>
</ul>
</div>
<div class='col green s5 offset-s1 '>
<ul>
<li>This column is green</li>
<li>This column's background colour ends at the end of this list</li>
</ul>
</div>
</div>
To get full height you can do following. jsfiddle
HTML
<nav class="blue darken-3">
<div class="nav-wrapper">
Chatter
<ul class="right hide-on-med-and-down">
<li><a nohref><i class="material-icons">search</i></a></li>
<li><a nohref><i class="material-icons">view_module</i></a></li>
<li><a nohref><i class="material-icons">refresh</i></a></li>
<li><a nohref><i class="material-icons">more_vert</i></a></li>
</ul>
</div>
</nav>
<div class="row">
<div class="col s3 red">1</div>
<div class="col s9 indigo">4</div>
</div>
jQuery
$(document).ready(function() {
window_size = $(window).height();
$('.col').height(window_size);
});
Second question, add this in your CSS-File:
div.col.s3.red {
min-height: 500px;
height: 100%;
}
div.col.s9.indigo {
min-height: 500px;
height: 100%;
}
It gives a height of 100% to the two elements, it should work in newer Browsers. For older Browser you could add min-height to it.
First Question, the nav elements have a line-height of 64px, you could reduce it as you like in your CSS-File:
.nav-wrapper {
line-height: 44px;
}
var resizeColumn = function () {
my_column_el.height($(window).height() - my_column_el.offset().top);
};
$(window).on('resize.column', _.debounce(resizeColumn, 300));
resizeColumn();
As with Bootstrap, most Materialize styling starts with a container. If the container is not 100% then child divs will not be either. This styling will start you off with 100% width and 100% height:
CSS
html, body {
min-height: 100vh;
margin: 0;
padding: 0;
}
.container {
min-height: 100vh;
width: 100%;
}
.content-wrapper-100vh {
min-height: 100vh;
}
Remove "width: 100%;" in the container css and it will be 70% wide (default).
HTML
<div class="container">
<div class="valign-wrapper content-wrapper-100vh">
<div class="row center-align">
<div class="col l12">
<div class="my-title">Centered/Middle Title</div>
</div>
</div>
</div>
</div>
Related
I have two tabs and they have bottom-borders. This is the jsfiddle example.
<div class="component-content">
<div class="tabs-inner">
<ul class="tabs-heading">
<li tabindex="0" class="active">
<div>
<div class="row">
<div class="component content col-12">
<div class="component-content">
<div class="field-heading">TAB 1: STANDARD SMALL</div>
</div>
</div>
</div>
</div>
</li>
<li tabindex="-1">
<div>
<div class="row">
<div class="component content col-12">
<div class="component-content">
<div class="field-heading">TAB 2: STANDARD SMALL</div>
</div>
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
.tabs-heading {
display: table;
table-layout: fixed;
width:100%;
}
.tabs-heading li {
display: table-cell;
border-bottom: 2px solid red;
}
I want to add padding in the border bottom so that it should look like this
I tried to add padding-bottom but it didn't work.
Any suggestion or help would be appreciated
I am not quite sure if I got your question right ... but maybe you are looking for something like this ...?
If you don't use table and table-cell ... but flexbox instead ... all tabs will get automatically the same height and you are able to work with padding-bottom. If you like you can add margins between tabs as well.
#wrapper {
display: flex;
align-items: stretch;
background-color: Gray;
}
#wrapper div {
padding-bottom: 10px;
border-bottom: 2px solid orange;
}
#one {
background-color: green
}
#two {
background-color: blue
}
#three {
background-color: red
<div id="wrapper">
<div id="one">one one one one one one one one one one one one one one one one one one one one one</div>
<div id="two">two two two two two two</div>
<div id="three">three</div>
</div>
While using my computer everything works well but once I test on my phone, I get a weird margin on the right, I changed the body background color to black & the margin's color is now black so I guess it comes from the body tag.
I can't give whole CSS code +1000 lines but here are the lines affecting margin / body
I tried to set body margin & padding to 0 but nothing.
* {
margin: 0;
padding: 0;
}
body {
background-color: #000;
margin: 0;
padding: 0;
min-height: 100vh;
width: 100%;
overflow-x: hidden;
font-family: 'PT Sans Narrow', sans-serif;
text-rendering: optimizeLegibility;
height: 100%;
}
#media (max-height: 400px) {
body {
height: 100vh;
}
}
<div class="open">
<div class="layer"></div>
<div class="layer"></div>
</div>
<div class="wrapper">
<div class="wrap">
<section>
<div class="header">
<h2 class="logo">Fallen Angels</h2>
<i class="fa fa-bars x2" onclick="menuToggle()" />
<ul id="navbar">
<li>Home</li>
<li>Accounts</li>
<li>Boosting</li>
<li>Contact</li>
<li>Login</li>
<li>Sign Up</li>
<i class="fa fa-times x2" onclick="menuToggle()"></i>
</ul>
</div>
<div class="bannerText">
...
</div>
</section>
</div>
</div>
I expected changing body's width to fix it but it just reduced the size of the whole thing including the margin :/
website preview : http://preview.fallen-angels.ga/
Normaly with this problem, I usually inspect the elements one by one. The problem with your case is this element:
<img src="assets/img/Xpreview.png" width="140%" style="padding-right: 40%;">
In small screens, the col-md-6 width is 100%. Padding right 40% add 40% of the element's width to the image. That's why it exceeds the screen width, and adds the extra space there.
You can use style="max-width:100%" to fix your problem.
So at you can write this instead:
<img src="assets/img/Xpreview.png" width="140%" style="max-width:100%">
Hi I have a container div for a page (called innercontent) and within that I have a div called tabs2. Tabs2 contains a tabbed navigation that allows content inside a div (within tab2) change. The content inside the div varies, so the height should expand itself if there is a lot of content in that div. The problem is that when changing the tabs in the content area, the div does not resize automatically, so the content cannot be seen. Here is the code:
CSS:
.innercontent {
overflow: hidden;
background-color:#FFF;
padding:24px 30px;
border-radius:5px;
}
#tabs2 {
width: 100%;
height:100%;
}
.div2 {
position: absolute;
visibility: hidden;
width: 100%;
left: 0;
}
HTML:
<div id="tabs2">
<ul>
<li id="One">One
<div class="div2">
<p>Insert content here</p>
</div>
</li>
<li id="Two">Two
<div class="div2">
<p>Insert content here</p>
</div>
</li>
<li id="Three">Three
<div class="div2">
<p>Insert content here</p>
</div>
</li>
</ul>
</div>
Are you sure they have to be absolute? As I don't think they need to be.You could look at using something such as jqueryui http://jqueryui.com/tabs/
Alternatively, amend your html and it should be easier.Essentially move the content divs outside of the but have a data-attribute that links them to a specific link. I'm assuming you use some js at the moment to manipulate showing and hiding as you currently have visibility:hidden. I've changed this to display:none in my example (as visibility still occupies space in the document. When a user clicks a link, hide all the divs by default, then show the one with the correct matching data-attribute.
I've created a fiddle at http://jsfiddle.net/9bH7s/ that shows this and the code is below.
html
<div class="innercontent">
<div id="tabs2">
<ul>
<li id="One">One
</li>
<li id="Two">Two
</li>
<li id="Three">Three
</li>
</ul>
<div class="div2" data-id="first">
<p>Insert content here</p>
</div>
<div class="div2" data-id="sec">
<p>Insert content here</p>
</div>
<div class="div2" data-id="third">
<p>Insert content here this has a lot more <br /><br />and some more content</p>
</div>
</div>
</div>
css
.innercontent {
overflow: hidden;
background-color:#efefef;
padding:24px 30px;
border-radius:5px;
}
#tabs2 {
width: 100%;
height:100%;
}
#tabs2 ul li{
float:left;
list-style:none;
margin-left:10px;
}
.div2 {
display:none;
width: 100%;
clear:both;
}
js
$('#tabs2').delegate('a','click',function(){
$('.div2').hide();
$('.div2[data-id=' + this.id +']').show();
});
1st change::dont indicate any height for .tab2..it will take an automatic height corresponding to the item that it contains
2nd change: you have made position:absolute; and expecting it to be dynamic.how that can be possible.remove it..either make it position:relative; or better choice is not to mention position property at al ...you can use margin-left:100px; to position your div
I am using Bootstrap's Navbar and Bootsrap's grid to display a Navbar with a image immediately underneath the Navbar. However, for some reason there is whitespace between this Navbar and the image. When I use firebug to investigate the location of the whitespace, it looks like the Navbar is top-aligned within its containing . I have tried to fix this by using CSS to bottom-align the navbar, to no avail.
How can I eliminate this whitespace?
<!-- Top Navigation Bar -->
<div class="row" id="rowTopLinkNavBar">
<div class="span6 offset3" id="divTopLinkNavBar">
<div class="navbar" id="topLinkNavBar">
<div class="navbar-inner" style="font-size: 16px;">
<ul class="nav">
<li class="active">Home</li>
<li class="divider">PROJECTS</li>
<li class="divider">ABOUT US</li>
<li class="divider">THE TEAM</li>
<li class="divider">EVENTS</li>
<li class="divider">MEETINGS</li>
<li>RESOURCES</li>
</ul>
</div>
</div>
</div>
</div>
<!--Background Image-->
<div class="row" id="rowBackgroundImg">
<div class="span6 offset3" id="backgroundImg">
<!-- background image is set in CSS -->
</div>
</div>
Here is my desperate attempt at fixing this issue using CSS:
#backgroundImg
{
color: #ff0000;
background-color: #000000;
/*width: 709px;
height: 553px;*/
background: url('../images/someImage.jpg') no-repeat;
background-size: 100%;
height: 700px;
border-radius: 0px;
background-position: center;
vertical-align: top;
background-position: top;
}
#divTopLinkNavBar
{
vertical-align: bottom;
}
#topLinkNavBar
{
padding-bottom: 0px;
}
#rowBackgroundImg
{
padding-top: 0px;
}
.navbar
{
vertical-align: bottom;
}
You may want to override the margin-bottom: 20px from navbar :
.navbar {
margin-bottom: 0;
}
Something like that : http://jsfiddle.net/q4M2G/
(the !important is here just to override the style of the CDN version of bootstrap I'm using in the jsfiddle but you should not need to use it if your style correctly overrides bootstrap styles)
Why you put classes: span12 offset3 ?
Bootstrap has 12 columns default. so if you didn't changed it try to put:
span9 offset3 or just span12.
So I have a bunch of elements that need to have a specific width, height and padding and need to be centered within their parent element:
<div class="pages">
<a>Page 1</a>
<a>Page 2</a>
<a>Page 3</a>
</div>
How do I do this? I don't know how many elements there will be so .pages can't have a defined width so margin:auto; won't work.
In the stylesheet or style tag:
margin-left: auto; margin-right: auto
You can wrap all those in one single div and center this one, this will be the usual approach I believe.
<div id="wrapper" style="margin-left:auto; margin-right:auto">
<div id="page1"> ... </div>
<div id="page1"> ... </div>
...
</div>
If you have working code, please post it.
It sounds like what you're looking for is margin: auto on the elements you want to center, like so:
#my_div {
margin: auto;
}
CSS CODE
div {
display:table-cell;
width: 200px;
height: 200px;
vertical-align:middle;
background: red;
}
HTML CODE
<div>
Hello...This is Vertically Centered!
</div>
<div>
Hello...2!
</div>
<div>
Hello...3!
</div>
SAMPLE DISPLAY