Compiling Bootstrap in LESS - How can I have a different navbar height for mobile? - css

My entire AngularJS website is reponsive. It is responsive to the screen size & loads the same pages for mobile, desktop, and tablet. However, I am having trouble getting the navbar to be a separate height on different devices in a responsive way.
Mostly, I just want the navbar to load at a slimmer height on mobile so that more of the screen space can be utilized for actual content that the user wants to see.
Right now, I am setting the height variable in variables.less which is where I know how to alter navbar height settings currently.
Variables.less
// Basics of a navbar
#navbar-height: 64px; // most relevant line!
#navbar-margin-bottom: #line-height-computed;
#navbar-border-radius: #border-radius-base;
#navbar-padding-horizontal: floor((#grid-gutter-width / 2));
#navbar-padding-vertical: ((#navbar-height - #line-height-computed) / 2);
#navbar-collapse-max-height: 340px;
#navbar-default-color: #gray-light;
#navbar-default-bg: #fff;
#navbar-default-border: transparent;
OK, so that is great, but I want 64px height to be set for desktop/tablet but 38px height to be set for navbar height on mobile screens.
I have already tried over-riding the navbar height in my local CSS with a media query but even with the !important flag it is not working to set the navbar to another height.
App.less <-- this doesn't work :(
#media (max-width: 767px) {
.navbar {
height: 35px !important;
}
.navbar-collapse ul li a {
line-height: 35px;
height: 35px;
padding-top: 0;
margin-top: 0px;
margin-bottom: 0px;
padding-bottom: 0px;
vertical-align: middle;
font-family: 'Open Sans', sans-serif;
font-weight: 700;
}
.navbar-brand li a {
line-height: 35px;
height: 35px;
padding-top: 0;
margin-top: 0px;
margin-bottom: 0px;
padding-bottom: 0px;
vertical-align: middle;
font-family: 'Open Sans', sans-serif;
font-weight: 700;
}
}
NOTE I am using Bootstrap 3. Also, if it makes any difference, Bootstrap is imported in the main app.less file like so: #import "bower_components/bootstrap/less/bootstrap.less";
What should I do? How can this be done in a responsive fashion?
(A.K.A. without making an entirely different site for mobile)
Thanks for all the help!

Based on comment above, I suggest you set min-height to 35px in your media query
.navbar {
min-height: 35px;
}

I think what prevents you to set the height is the min-height property set to the element with class navbar.
Adding min-height: 35px would be enough:
#media (max-width: 767px) {
.navbar {
height: 35px;
min-height: 35px;
}
...

Try the following syntax:
#media only screen and (max-width: 767px) {
.navbar {
height: 35px !important;
}
.navbar-collapse ul li a {
line-height: 35px;
height: 35px;
padding-top: 0;
margin-top: 0px;
margin-bottom: 0px;
padding-bottom: 0px;
vertical-align: middle;
font-family: 'Open Sans', sans-serif;
font-weight: 700;
}
.navbar-brand li a {
line-height: 35px;
height: 35px;
padding-top: 0;
margin-top: 0px;
margin-bottom: 0px;
padding-bottom: 0px;
vertical-align: middle;
font-family: 'Open Sans', sans-serif;
font-weight: 700;
}
}

Related

HTML: sticky header jumps a little bit when scrolling

The problem is, that I'm trying to keep my header just stay at the top, when scrolling into other pages (inside) and when i'm selecting some of the other pages (with a lot of text) which makes scroll -> appear, the header jumps a little bit, which is annoying.
I tried text-align into a parent div and display: inline-block; into secondary. Tried to do the div relative and with left px etc but that makes it very unresponsive.
.header {
text-align: center;
}
.header h1 {
display: inline-block;
font-size: 77.2px;
font-style: normal;
font-weight: normal;
letter-spacing: normal;
line-height: 76px;
text-transform: none;
font-family: "Great Vibes", cursive;
}
.content {
margin: 0 auto;
width: 960px;
top: 20px;
z-index: 0;
padding: 20px;
}
The only way i actually can get it as i want is to set a wrapper with display: inline-block; and text-align: center with left: right 50 % and positio relative; looks as follows, problem is it doesnt really center and it's not responsive for bigger screens etc:
.header {
display: inline-block;
}
.header h1 {
text-align: center;
left: 50%;
right: 50%;
position: relative;
font-size: 77.2px;
font-style: normal;
font-weight: normal;
letter-spacing: normal;
line-height: 76px;
text-transform: none;
font-family: "Great Vibes", cursive;
}
It can be possible that there is an element (most commonly an image or video) that is wider than 100%. This causes somehow to screw things up a bit when having a fixed or sticky header. Try setting the max-width of the problematic element to 100%.

Making my boxes responsive in css

I have 8 boxes on my html file, when viewing on the desktop, everything looks OK, visited on the mobile and the colums are way off than it should be, it should be in the center, not in the right side, how would i do that to make it responsive?
Preview
My code for the columns.
.articles {
margin: 100px;
background-color: #F5F5F5;
}
.article {
margin: 5px;
display: inline-block;
width: 340px;
position: relative;
float:left;
left: 155px;
box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12);
}
.article-image {
width: 100%;
}
.article-text-wrapper {
padding: 20px;
}
.article-title {
font-family: 'Roboto', sans-serif;
font-size: 20px;
font-weight: 700;
}
.article-description {
font-family: 'Roboto', sans-serif;
line-height: 16px;
font-size: 16px;
color: rgba(0,0,0,0.7);
font-weight: 300;
}
.article-time {
font-family: 'Roboto', sans-serif;
font-size: 12px;
color: rgba(0,0,0,0.4);
font-weight: 300;
}
Thanks alot.
You have left and margin properties applied to your article elements. You will need to add a media query for the following:
#media only screen and (max-width:700px) {
.articles {
margin: 50px 0;
}
.article {
left: 0;
width:100%;
}
}
The problem is that your article has fixed width, float and is displayed as inline-block.
Try by adding the following media query:
#media only screen and (max-width : 768px) {
.article {
margin: 0 auto;
display: block;
width: 100%;
max-width: 340px;
float: none;
left: auto;
}
}
When making responsive web pages, add the following element in all your web pages:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Set CSS width property is set to 100% for images, the image will be responsive and scale up and down. And also use max-width property.
For better responsive design use Media Queries.
#media screen and (max-width: 800px) {
.class-name {
width: 100%; /* The width is 100%, when the viewport is 800px or smaller */
}
}
Refer here

CSS makes div unequal in firefox and chrome

I've made two divs for navigation with given css:
for first button:
.OptionsButton .DropDownButtonOverlay
{
margin: 0px -95px 0px 0px;
width: 92px;
height: 38.5px;
float: right;
z-index: 2;
}
.tenPxLeft
{
margin-left: 10px;
}
.floatRight
{
float: right;
}
.regularButton
{
background-color: #008BE1;
border: none;
}
.optionsButton
{
border-radius: 3px;
-webkit-appearance: none;
}
and the second button is as this:
.defaultButton
{
font-family: 'Open Sans', Segoe UI, Verdana, Helvetica, Sans-Serif;
border-radius: 3px;
font-size: 14px;
color: #FFFFFF;
padding: 10px 15px;
-webkit-appearance: none;
margin: 0; /* fixes chrome bug */
}
.tenPxLeft
{
margin-left: 10px;
}
.floatRight
{
float: right;
}
.regularButton
{
background-color: #008BE1;
border: none;
}
the problem I am dealing with is they look fine on Chrome and IE (alligned nicely). However when I go to firefox they don't get alligned as well as intended (i am putting them in another div as a top menu thingy).
It seems like the font is influencing that. I've tried making font by percentage (100.01%), however it makes it look nice in firefox, but then ruins the view in IE and Chrome.
how could I fix this?
I found out that firefox tends to work differently on divs (I knew this before, but the solution was unclear), therefore I added Max-Height attribute on the button that expands due to text-size in it's body which fixed the problem.

Why isn't my 320px media query being applied?

I have the following two media queries:
#media (min-width: 320px) and (max-width: 359px){
.hero-unit h1 {
margin-bottom: 0;
font-size: 0.2em;
line-height: 0.5em;
letter-spacing: -5px;
color: inherit;
}
.hero-unit p {
font-size: 0.2em;
font-weight: 10;
line-height: 0.5em;
color: inherit;
}
.hero-unit {
background: url("../img/now320.jpg");
height: 5em;
width: 15em;
padding: 0.5em;
margin-bottom: 2em;
background-color: #eeeeee;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
h2 {
font-size: 2em;
font-weight: 20;
line-height: 0.5em;
color: inherit;
}
}
#media (min-width: 360px) and (max-width: 479px) {
.hero-unit h1 {
margin-bottom: 0;
font-size: 0.2em;
line-height: 1em;
letter-spacing: -5px;
color: inherit;
}
.hero-unit p {
font-size: 0.2em;
font-weight: 50;
line-height: 1em;
color: inherit;
}
.hero-unit {
background: url("../img/now360b.jpg");
padding: 1em;
margin-bottom: 2em;
height: 10em;
width: 18em;
background-color: #eeeeee;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
}
h2 {
font-size: 2em;
font-weight: 20;
line-height: 1em;
color: inherit;
}
}
I'm trying to figure out why the 320 width rule is not being applied at all to my HTML page, even though I've resized it using the responsive design tool in Firefox to have a width of 320px.
I checked the CSS styles using Firebug to see what's going on. I only see the #media (min-width: 360px) and (max-width: 479px) part being applied. That is, its not a case where the CSS rule I think should be applied is being overwritten. What's happening is the rule is never applied at all. Why?
Sometimes browsers just simply don't allow for a viewport to be smaller than a certain size, and I think that line is down around 360, so it may simply not be registering, even with the tool you mention. I can't say, because I'd need to see the live example.
Have you checked the site on an actual mobile device, or at least an emulator? The Opera Mobile Emulator is pretty easy to use.
As an aside, if you want to work mobile first - there is the idea of writing your CSS for 320 devices first, with no media query, as the 'baseline' experience. That is where you specify font families, colors, generally applied styles. Then you add in media queries to work on larger and larger sizes, and that is where you specify changes in layout and text size. The point being - don't wrap your 320-359 styles in a media query as it will be the basic experience for everyone.
If you wish the 320px rule to be applied for all the page you need to write it like this
#media (min-width: 320px)
without any and (min-width....) after it

Google maps api v3 infobubble css Firefox

I have an infoBubble with some text and images. The right aligned image (arrow) is pushed down in Firefox (Mac) but not Safari or Opera dependent on the length of the text to the left and above. See the marker over Australia: http://www.hostelbars.com/map_test_v3_3.html
Here's the css:
.infowindow {
background-color: #000;
color: #FFF;
font-size: 18px;
font-family: Helvetica Neue, Helvetica, Arial;
text-shadow: 0 -1px 0 #000;
font-weight: bold;
position: relative;
overflow: hidden;
}
.infowindow .iwPhoto {
background-color: #F00;
position: relative;
padding-bottom: 1px;
padding-top: 2px;
padding-left: 5px;
}
.infowindow .iwName {
background-color: #0F3;
line-height: 33px;
white-space: nowrap;
position: relative;
margin-left: 115px;
margin-top: -70px;
padding-right: 5px;
padding-top: 2px;
}
.infowindow .iwCity {
background-color: #C03;
line-height: 32px;
margin-left: 115px;
padding-bottom: 1px;
}
.infowindow .iwCity .iwArrow {
background-color: #0CF;
padding-right: 5px;
padding-left: 5px;
margin-top: 3px;
float: right;
}
Aside from the images I don't want the div's to have a fixed width. Would appreciate some help.
Brendon
Seems to only happen the first time, and for items with city values longer than name values. This suggests you didn't set width and height values for your img element (arrow.png), so the first time it has no idea what size it's going to be, and subsequent times it does.
What you should probably do is change it to a background image, as it's merely an iconified decorative image meaning 'next' or 'more', and thus should be in CSS's realm of style, not HTML's realm of meaning (where 'img' lives). See this list of image replacement techniques.
Otherwise, you could just apply img[src$="arrow.png"] { width: 29px; height: 29px; }, or add width and height attributes to the img element.

Resources