Trying to make my site responsive - css

I am using the following css code. What I want to do is if the user is on a iPad I want the background-image to be headerold.jpg or some way to make the current headernew.jpg to display properly on the iPad. Currently part of each end is cut off. I have tried #media query but I am not able to get the code to work. Any help would be appreciated.
Thanks Roger
div.art-header-jpeg
{
position: absolute;
top: 0;
left:-50%;
width: 1344px;
height: 150px;
background-image: url('../img/headernew.jpg');
#media all and (max-width: 1000px) {background-image: url('../img/headerold.jpg');}
background-repeat: no-repeat;
background-position: center center;
}

You could do something like this.
CSS:
img.bg {
/* Set rules to fill background */
min-height: 100%;
min-width: 1024px;
/* Set up proportionate scaling */
width: 100%;
height: auto;
/* Set up positioning */
position: fixed;
top: 0;
left: 0;
}
#media screen and (max-width: 1024px) { /* Specific to a particular image (change accordingly*/
img.bg {
left: 50%;
margin-left: -512px; /* 50% */
}
}
However there are different methods including a JQuery Method. You should check out some discussion about it here.

I am trying to get the headernew.jpg to display on an iPad properly as well as other computer screens but first just the iPad. If I remove the position: absolute then the complete header moves to the right and only shows about 50% of the header. Is there something I need to add like suggested in another post like this ..
<meta name="viewport" content="width=device-width, initial-scale=1">
if so where should it be placed?
My code now looks like this;
div.art-header-jpeg
{
position: absolute;
top: 0;
left:-50%;
width: 1344px;
height: 150px;
#media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
div.art-header-jpeg
background-image: url('../img/headernew.jpg');
}
background-repeat: no-repeat;
background-position: center center;
}

Related

Correcting Media Query syntax to make web page responsive to mobile phone

I'm having trouble making the header video (on the homepage) and the header image on the other pages responsive to mobile phone when held in portrait. What I'm aiming for is similar to when you watch a YouTube video in portrait on your mobile phone. When holding your phone in portrait, the video takes up the top third of the screen. And when you hold the phone in landscape, the video takes up the whole screen. I would like to have the same effect for the header video (on the homepage) and the header image on the other pages of the site.
What I have attempted to do is use Media Queries so that when the screen reaches a max-width: 480px, the screen adjusts. But I keep running into different road-blocks. All of these road-blocks revolve around the pages not syncing up the way I want them to.
Here is where I am at with the code:
/* portrait mobile phone display */
#media only screen and (max-width: 480px), (orientation: portrait) {
/* header */
.header {
height: auto;
margin-top: auto;
}
/* header video */
.header-video {
position: absolute;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
bottom: 0;
right: 0;
min-width: 100%;
min-height: 100%;
width: 100%;
height: auto;
z-index: -1;
}
#media(min-aspect-ratio: 16/9) {
.header-video {
width: 100%;
height: auto;
}
}
#media(max-aspect-ratio: 16/9) {
.header-video {
width: auto;
height: 100%;
}
}
/* header image */
.header-image {
position: absolute;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
bottom: 0;
right: 0;
min-width: 100%;
min-height: 100%;
width: 100%;
height: auto;
z-index: -1;
}
#media(min-aspect-ratio: 16/9) {
.header-image {
width: 100%;
height: auto;
}
}
#media(max-aspect-ratio: 16/9) {
.header-image {
width: auto;
height: 100%;
}
}
}
Also, I am happy with how the site is displayed on my laptop and when viewed in landscape on my mobile, and I don't want to lose this.
I feel that I am on the right track, but I just don't have the syntax quite right at this stage. Just seeking a bit of guidance on this.
Thanks in advance.

CSS media query nota recognized with :before element

This Code isnt working and I dont understand what is happening, since everything else is working fine and I have the meta viewport tag on the header:
.content {
width: 100%;
height: 100%
}
.content:before {
content: '';
position: absolute;
top: 5%;
left: 5%;
}
#media (max-width: 1024px) {
.content:before {
top: 15%;
left: 15%;
}
}
I tried to modify the media with screen and min-width. I also tried to swap the medias position and nothings showing on Google chromes dev console, while other medias and rules are showing and working properly.
Is it posible to modify those attributes on that kind of element with CSS?
Thanks
You're missing the unit in your media query:
#media (max-width: 1024px) {
.content:before {
top: 15%;
left: 15%;
}
}

Remove background header image in mobile view on certain page on Squarespace website

The website url is: http://www.georjart.com/paintings-new
The password is: M6NYey7f
I've added a background image to the header of a specific page on this Squarespace website above using the following code:
#collection-6058d724f45e96664a810213 header#header {
background-image: url(https://www.emergentcreative.co.uk/wp-content/uploads/2021/04/Gart-BG-Header-Example-1-2.jpg);
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
position: absolute;
top: 0;
right: 0;
margin-bottom: 9px;
padding: 40px
}
However when I go to mobile view it looks like this:
I can see that the issue is with the "position" and "background-image" code and by going into Dev Tools in Chrome I can edit the following media query:
#media only screen and (max-width: 750px)
#header {
background-image: none !important;
position: inherit !important;
}
I can get it too look normal:
However I'm not certain how to add this code into the CSS editor in Squarespace, let alone on a specific page which is what I'd like to do since the changes aren't live yet.
Does anyone have a solution?
Cheers,
M.
Using your approach of an absolutely-positioned header as a starting point (and without reworking that approach), I would do the following in place of what you have now.
#collection-6058d724f45e96664a810213 #header {
background-image: url("https://www.emergentcreative.co.uk/wp-content/uploads/2021/04/Gart-BG-Header-Example-1-2.jpg");
background-size: cover;
background-position: center right;
background-repeat: no-repeat;
position: absolute;
top: 0;
left: 0;
}
#media only screen and (min-width: 750.1px) {
#collection-6058d724f45e96664a810213 #header {
margin-bottom: 9px;
padding: 40px
}
}
#media only screen and (max-width: 750px) {
#collection-6058d724f45e96664a810213 #header {
margin-left: -20px;
margin-right: -20px;
padding-top: 35px;
padding-bottom: 35px;
padding-right: 20px;
padding-left: 20px;
}
}

how to specify width for material 2 bottom sheet in different resolution

I have page which is divided into two vertical panes. The left and right panes respond to differnt resolutions.
<div fxLayout="row" fxFlexFill fxLayout.xs="column" >
<div fxFlex="20" class="width" fxFlex.sm="45" fxFlex.md="35" fxFlex.lg ="30" >
left div
</div>
<div fxFlex="80" fxFlex.sm="55" fxFlex.md="65" fxFlex.lg ="70">
//div rendering bottomsheet
</div>
I am opening the bottomsheet like this in my component
openBottomSheet() {
this.closeBottomSheet();
const config: MatBottomSheetConfig = {
hasBackdrop: false,
disableClose: false,
panelClass: 'bottom-sheet-container',
direction: 'ltr'
};
this.matRef = this._bottomSheet.open(DiagnosticCompanionComponent, config);
}
this is bottom-sheet-container class:
.bottom-sheet-container {
// margin-left: 465px !important;
position: absolute;
bottom: 0px;
right: 10px;
width: calc(100vw - 485px) !important;
min-width: 0% !important;
}
Earlier my left div was having fixed width of '485px' and hence i was able to render my bottom sheet in remaining space. But now as I have made page responsive,I am unable to figure out, how to specify bottom sheet width for different resolutions in angular flex-layout.
Angular Material automatically adds the following classes based on the size of your screen:
.mat-bottom-sheet-container-medium {
min-width: 384px;
max-width: calc(100vw - 128px)
}
.mat-bottom-sheet-container-large {
min-width: 512px;
max-width: calc(100vw - 256px)
}
.mat-bottom-sheet-container-xlarge {
min-width: 576px;
max-width: calc(100vw - 384px)
}
Just add this code to your styles.css / styles.scss and change the values as needed.
I was able to solve my problem, by writing media queries as shown below.But i am unsure if this is best appraoch
.bottom-sheet-container {
// margin-left: 465px !important;
position: absolute;
bottom: 0px;
right: 10px;
width: 78%;
#media screen and (min-width: 600px) and (max-width: 959px) {
width : 51%;
}
#media screen and (min-width: 960px) and (max-width: 1279px) {
width : 62%;
}
#media screen and (min-width: 1280px) and (max-width: 1919px) {
width : 67%;
}
// width: calc(100vw - 485px) !important;
min-width: 0% !important;
z-index: 0 !important;
}
Try this.
::ng-deep .mat-bottom-sheet-container{
min-width: 100vw!important;
}

Back slashes being added to background-url in browser

I am trying to activate a background image in my custom CSS in Wordpress.
I have pasted it in, but when I inspect the element in Chrome. Back slashes have been added in front and on the end of the url. Meaning the image will not display.
Why are these being added? here is the patch and shown below what is added:
background-image: url(\"wp-content/uploads/2016/01/my-logo-backgroundurl.png\");
Also does the same when I put the full url path in
background-image: url("http://example.com/wp-content/uploads/2016/01/my-logo-backgroundurl.png");
#media (max-width: 768px) and (min-width: 475px)
#header-logo-image {
position: relative;
top: -10px;
left: 0;
background-image: url("wp-content/uploads/2016/01/my-logo-backgroundurl.png");
width: 250px;
height: 100px;
background-repeat: no-repeat;
margin: 0 auto;
}
I know its over a year and a half later, but I had this same problem and when I did a google search this was the page was the first entry. I fixed this by removing the quotes. This should work:
background-image: url(wp-content/uploads/2016/01/my-logo-backgroundurl.png)
I don't have enough reputation to comment directry, so I write to here. As #Paulie_D says, it can be fixed like this:
#media (max-width: 768px) and (min-width: 475px) {
#header-logo-image {
position: relative;
top: -10px;
left: 0;
background-image: url("wp-content/uploads/2016/01/my-logo-backgroundurl.png");
width: 250px;
height: 100px;
background-repeat: no-repeat;
margin: 0 auto;
}
}
If you want to use #media Rule, I guess this might be helpful. CSS3 #media Rule

Resources