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
Related
I have problems with the media-query, it detects me well the first but when they are less than 768px it no longer detects the average
this are my media-querys.
#media screen and (max-width:1920px){
#log {
bottom: 36%;
left: 35%;
}
}
#media screen and (max-width:1440px){
#log {
left: 41%;
width: 57%;
bottom: 30%;
}
#img2 {
width: 100%;
}
}
#media screen and (max-width:1024px){
#log {
left: 61%;
width: 72%;
bottom: 30%;
}
#img2 {
width: 100%;
}
}
#media screen and (max-width:765px){ /***** this is the one that does not work
#Table_01 {
margin-top: -12%;
}
}
You can try this: jsfiddle Demo
#Table_01 {
display: block;
width: 100%;
height: 500px;
border: 1px solid black;
margin-top: 20px;
}
#media screen and (max-width: 768px) {
#Table_01 {
margin-top: -12%;
}
}
<table id="Table_01"></table>
Note: in some #media questions you have 2 spaces, try to use one only to avoid any possible issue.
The last media query just works when the width of the screen is equal or lower than 765px not 768px. Also need to close the comment with */
#media screen and (max-width:768px) { /* this is the one that does not work */
#Table_01 {
margin-top: -12%;
}
}
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;
}
}
On my website I am trying to use media quieres to specify a mobile size, tablet size, and desktop size. Well, when I make edits to the tablet it applies those edits to the whole page instead of just when its sized to a tablet. What can I do to stop this and continue with the responsive design.
#media (min-width:320px) { /* smartphones, iPhone, portrait 480x320 phones */
nav{
width: 100%;
float: left;
text-align: center;
min-height: 50px;
}
nav > ul {
margin-top: 50px;
padding: 0;
display: none;
list-style: none;
}
nav > ul > li, nav > ul > li > a {
line-height: 20px;
display: list-item;
margin-left: 0;
font-size: 26px;
}
.hamburger {
padding: 20px;
display: block;
float: left;
text-align: center;
color: #fff;
font-size: 40px;
cursor: pointer;
}
}
#media screen and (max-width: 768px) {
/* portrait tablets, portrait iPad, landscape e-readers, landscape 800x480 or 854x480 phones */
nav{
width: 100%;
float: left;
text-align: center;
}
nav > ul {
margin-top: 50px;
padding: 0;
display: none;
list-style: none;
}
nav > ul > li, nav > ul > li > a {
line-height: 0px;
display: list-item;
margin-left: 0;
}
.hamburger {
padding: 20px;
display: block;
float: left;
text-align: center;
color: #000;
font-size: 10px;
cursor: pointer;
}
}
You can follow this query sequentially. Hope that it would be help.
/* Large screen desktop */
#media (min-width: 1170px) and (max-width: 1365px){
}
/* Normal desktop :992px. */
#media (min-width: 992px) and (max-width: 1169px) {
}
/* Tablet desktop :768px. */
#media (min-width: 768px) and (max-width: 991px) {
}
/* small mobile :320px. */
#media (max-width: 767px) {
}
/* Large Mobile :480px. */
#media only screen and (min-width: 480px) and (max-width: 767px) {
}
To get responsive images you have a few options.
Designate by general size using scrset:
Small: Under 600 px aimed at mobile users
Medium: Between 600 px-900 px aimed at midsized computer and tablets
Large: Over 900 px aimed at desktop monitors.
Scrset can also be used to designate percentages of screen space. For example, if you want the image to cover the full width of the screen you would use 100%. Then the browser will adjust the image to 100% width for the screen size of the visitor, regardless of the device.
You can also use the tag and the auto option for the size parameters. Such as: <img> width=auto height=auto. This will use client information to size the image.
Thirdly, while not as widely accepted, you can use client_hints=true along with the auto size option to get responsive images. This feature is fully supported by Chrome, not yet by other popular browsers.
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%;
}
I'm having some odd space issues on the left of my site. For some reason there is slightly more space on the left than on the right in mobile view, thus looking off-centered. I'm guessing its off for desktop view as well, but its not noticeable. I can't figure out what is making it this way. http://jeffreydowellphotography.com/
/* ---------->>> MOBILE gap/space issues <<<-----------*/
#media screen and (max-width: 400px) {
#pageWrapper { margin: 0;}
.sqs-layout .sqs-row .sqs-block:last-child {
padding-bottom: 0;
padding-top: 0;
}}
/* ---------->>> MOBILE center logo <<<-----------*/
#media only screen and (max-width: 400px) {
h1.logo {
text-align:center;
margin-bottom: 20px !important;
}}
/* ---------->>> MOBILE logo size <<<-----------*/
#media only screen and (max-width: 400px) {
.logo-image .logo img {
max-height: 110px;
margin: 5px;
width: auto;
}
.social-links {
padding-top: 20px;
}}
Try removing the margin: 5px; on .logo-image .logo img in your mobile styles. The image with the margin may be wider than the div that contains the image and it comes off as being non-centered.
UPDATE
I took a look at your site, its actually the margin on the .slide selector. Add this in your mobile styles:
.slide { margin: 0; }