I have a md-toolbar from Angular material 2 which is fixed on the page
<md-toolbar id="floating-toolbar" color="primary"></md-toolbar>
<md-progress-bar *ngIf="true" class="floating-progress" mode="indeterminate" color="accent"></md-progress-bar
#floating-toolbar {
position: fixed;
z-index: 1001;
}
I want to put a progress bar underneath that fixed tool-bar. What I am finding that AngularMaterial2's md-toolbar height changes based on the screen width. So I have painfully worked out the following by looking at the view port
#media (max-width: 599px){
.floating-progress {
position: fixed;
margin-top: 56px;
z-index: 1002;
}
}
#media (min-width: 600px) and (max-width: 650px){
.floating-progress {
position: fixed;
margin-top: 64px;
z-index: 1002;
}
}
#media (min-width: 651px) and (max-width: 959px){
.floating-progress {
position: fixed;
margin-top: 48px;
z-index: 1002;
}
}
#media (min-width: 960px) {
.floating-progress {
position: fixed;
margin-top: 64px;
z-index: 1002;
}
}
This seems to work ONLY when the height of the page is full screen on my desktop though. As soon as I reduce the height (Simulating a smaller screen or screen in portrait, these rule are no longer valid as the tool bar's height seems to be a variable of the both width AND height.
Is there a way to easily fix this such as simply snapping the progress bar below that fixed position tool bar.
I have found this in the md-toolbar's scss file which may help?
//toolbar.scss
$md-xsmall: 'max-width: 600px';
$md-small: 'max-width: 960px';
$md-toolbar-height-desktop: 64px !default;
$md-toolbar-height-mobile-portrait: 56px !default;
$md-toolbar-height-mobile-landscape: 48px !default;
$md-toolbar-font-size: 20px !default;
$md-toolbar-padding: 16px !default;
#mixin md-toolbar-height($height) {
md-toolbar {
min-height: $height;
}
md-toolbar-row {
height: $height;
}
}
md-toolbar {
display: flex;
box-sizing: border-box;
width: 100%;
// Font Styling
font-size: $md-toolbar-font-size;
font-weight: 400;
font-family: $md-font-family;
padding: 0 $md-toolbar-padding;
flex-direction: column;
md-toolbar-row {
display: flex;
box-sizing: border-box;
width: 100%;
// Flexbox Vertical Alignment
flex-direction: row;
align-items: center;
}
}
// Set the default height for the toolbar.
#include md-toolbar-height($md-toolbar-height-desktop);
// Specific height for mobile devices in portrait mode.
#media ($md-xsmall) and (orientation: portrait) {
#include md-toolbar-height($md-toolbar-height-mobile-portrait);
}
// Specific height for mobile devices in landscape mode.
#media ($md-small) and (orientation: landscape) {
#include md-toolbar-height($md-toolbar-height-mobile-landscape);
}
/*toolbar.css*/
md-toolbar,md-toolbar md-toolbar-row {
display:flex;
box-sizing:border-box;
width:100%
}
md-toolbar{
font-size:20px;
font-weight:400;font-family:
Roboto,"Helvetica Neue",sans-serif;
padding:0 16px;
flex-direction:column;
min-height:64px
}
md-toolbar md-toolbar-row{
flex-direction:row;
align-items:center
}
md-toolbar-row{
height:64px
}
#media (max-width:600px) and (orientation:portrait){
md-toolbar{
min-height:56px
}
md-toolbar-row{
height:56px
}
}
#media (max-width:960px) and (orientation:landscape){
md-toolbar{
min-height:48px
}
md-toolbar-row{
height:48px
}
}
I have solved this by putting the md-toolbar and md-progress bar inside a floating-header-div class as one unit. That way progress bar is always below the toolbar regardless of the size
<!--floating header-->
<div class="floating-header-div">
<md-toolbar>
<button md-icon-button class="ml-xs toolbar-button" (click)="sidenav.toggle()">
<md-icon id="menu-icon">menu</md-icon>
</button>
<span id="app-title">MyApp</span>
</md-toolbar>
<md-progress-bar *ngIf="isLoading" mode="indeterminate" color="accent"></md-progress-bar>
</div>
/*------------------------------*/
/*tool bar*/
/*------------------------------*/
.floating-header-div {
position: fixed;
z-index: 999;
width: 100%;
}
Related
So I am at the beginning, doing different tutorials and challenging myself with conquering the fundamentals. I know this might seem lowkey for most people but be gentle, i'm sorta new to this.
I tried using Media Queries 4 for example #media (30em <= width <= 50em ) { ... } but it jsut doesn't work for me (browser compatibility is checked btw) so I went with a classic code writing (which you may see below). Unfortunately my divs will not scale properly, I am clearly missing something like a parent-child not sharing the proper settings but I can't see it. Could you point out my mistake please? All it needs to do is scale the divs if the width is lower than 600, between 601 and 960 and above 961 (obv .px)
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Mobile Styles */
#media only screen and (max-width: 600px) {
body {
background-color: #F09A9D;
}
}
/* Tablet Styles */
#media only screen and (min-width: 601px) and (max-width: 960px) {
.sign-up,
.feature-1,
.feature-2,
.feature-3 {
width: 50%;
}
}
/* Desktop Styles */
#media only screen and (min-width: 961px) {
.page {
width: 960px;
margin: 0 auto;
}
.feature-1,
.feature-2,
.feature-3 {
width: 33.3%;
}
.header {
height: 400px;
}
}
.page {
display: flex;
flex-wrap: wrap;
}
.section {
width: 100%;
height: 300px;
display: flex;
justify-content: center;
align-items: center;
}
.menu {
background-color: #5995DA;
height: 80px;
}
.header {
background-color: #B2D6FF;
}
.content {
background-color: #EAEDF0;
height: 600px;
}
.sign-up {
background-color: #D6E9FE;
}
.feature-1 {
background-color: #F5CF8E;
}
.feature-2 {
background-color: #F09A9D;
}
.feature-3 {
background-color: #C8C6FA;
}
The html is just a bunch of divs with an img src inside them. The output is the same no matter what the size of the browser window is.
#sbrrk is right. And also, you should write your media queries at the very bottom, so they will override other rules of the same specificity
i have a codepen in which there is a dismissible drawer with top app bar component
which on resizing to 598px width the top app bar width decreases from 64px to 56px
but when using #media query to align it the drawer is not aligning please can you give a solution to this
codepen >>> https://codepen.io/BhavyaSingh2003/pen/NJbGoO
#media all and (max-width: 599px) {
.mdc-drawer--dismissible {
top: 56px;
height: calc(100% - 56px);
}
}
This CSS declaration:
.app-drawer-layout .mdc-drawer--dismissible
has more specificity (weight) than just:
.mdc-drawer--dismissible
So you can either write selector with the same specificity:
#media all and (max-width: 599px) {
.app-drawer-layout .mdc-drawer--dismissible {
top: 56px;
height: calc(100% - 56px);
}
}
...or add !important to your CSS:
#media all and (max-width: 599px) {
.mdc-drawer--dismissible {
top: 56px !important;
height: calc(100% - 56px) !important;
}
}
I'm fairly new to the world of scripts and coding, so I do not know the best terms to use.
I am trying to make a somewhat simple website, and I want my header background to have padding-bottom 120px at min-width 600px, and 0 at 1050. However, the padding-bottom only updates when changed in the properties for header.
Here is my code:
header {
border-radius: 5px;
display: block;
width: auto;
min-height: 200px;
background: #E44;
padding-top: 40px;
padding-left: 38px;
padding-right: 38px;
padding-bottom: 136px;
}
#media screen and (min-width: 600px) {
.header {
padding-bottom:120px
}
}
#media screen and (min-width: 1050px) {
.header {
padding-bottom: 0px;
}
}
The padding-bottom stays at 136px no matter the min-width of the window.
Make sure that you know the difference the dot does. .header is selection the header class. While header selects the element. Your code works fine, as you can see here, I'm using the media queries to change the background color instead of padding, just to make the point clear.
Fiddle example
header {
border-radius: 5px;
display: block;
width: auto;
min-height: 200px;
background: #E44;
padding-top: 40px;
padding-left: 38px;
padding-right: 38px;
padding-bottom: 136px;
}
#media screen and (min-width: 600px) {
.header {
background-color: blue;
}
}
#media screen and (min-width: 1050px) {
.header {
background-color: green;
}
}
<header class="header">
</header>
There is a small typo here. You have an additional dot(.) which will mean a class selector as against the other style which is on element selector.
#media screen and (min-width: 600px) {
header {
padding-bottom:120px
}
}
#media screen and (min-width: 1050px) {
header {
padding-bottom: 0px;
}
}
Hello guys I am using the following code to show and hide some elements but it seems to doesn't work on mobile devices.
#media screen and (max-width: 768px) and (orientation : portrait) {
.drawer1 {
display: block;
top: 789px;
}
.drawer {
display: none;
}
.drawer1-content {
background: #fff;
background-repeat: no-repeat;
border-collapse: collapse;
height: 645px;
width: 100%;
}
}
#media screen and (min-width: 769px) {
.drawer {
bottom: 0px;
height: 700px;
overflow: hidden;
position: absolute;
width: 1024px;
z-index: 5;
}
.drawer1 {
display: block;
}
..from the code you posted, looks like you miss a } at the end..
Also check if your device has a width less than 768px in the first case
and it has a width more than 769px in the second case (landscape or portrait)
try one of the several extensions available on Chrome/Firefox/Opera to set the max width of the viewport and simulate a mobile device..
From the comment:
so from the specs: IPAD 3gen: 2048-by-1536 pixel....here you have your answer :D just change the max-width and min-width ..or just use the landscape and portrait attributes
I have problem with the fixed div box with different screen size, the box is look perfect when the resolution is in 1366*768, but if the screen goes to bigger or smaller resolution, the box is running out of its position, which is not aligned with the container, as illustrate of the below image.
Could it be properly place and align the box with different screen resolution?
*Note: The div box will shrink to edge when the page is scrolling down.
Fixed div:
<a href="#" data-toggle="modal" data-target="#modalBox">
<div class="adv"><span">Big Hi to World</span></div>
</a>
CSS:
.container {
width: 1054px;
}
.adv {
position: fixed;
top: 12px;
right: 12%;
width: 230px;
height: 56px;
background-color: #348cb2;
text-align: center;
z-index: 9998;
}
.adv:hover {
background-color: #6fc7bb;
}
.adv span {
display: block;
text-transform: uppercase;
letter-spacing: 4px;
font-size: 26px;
font-weight: 300;
color: #fff;
padding: 12px;
line-height: 110%;
}
.adv-ts {
right: 0;
width: 48px;
height: 48px;
-webkit-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
opacity: 1.0;
}
.adv-ts span {
display: none;
}
.adv-ts:after {
content: "Hi";
font-size: 28px;
color: #fff;
padding: 13px 11px;
display: block;
}
Appreciate for solution!
Try using CSS media queries
/* Small devices (tablets, 768px and up) */
#media (min-width: 768px) { ... }
/* Medium devices (desktops, 992px and up) */
#media (min-width: 992px) { ... }
/* Large devices (large desktops, 1200px and up) */
#media (min-width: 1200px) { ... }
With each screen size change the position of the adv