Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS Please help a graphic designer who knows nothing about code with her Cargo site

Sarah M.

New Coder
Problem: On my cargo site (which isn't live yet) images enlarge infinitely when browser grows. How do I put a max size on them? It's to show off a mobile app and it looks bad when it becomes giant.

I've tried this:

.mobile {
max-height: 800px;
}

It works on desktop, but on mobile it won't shrink properly.

Thanks!
 
Problem: On my cargo site (which isn't live yet) images enlarge infinitely when browser grows. How do I put a max size on them? It's to show off a mobile app and it looks bad when it becomes giant.

I've tried this:

.mobile {
max-height: 800px;
}

It works on desktop, but on mobile it won't shrink properly.

Thanks!
Hey there :)
You can add what we call a media-query to your css. The purpose of the media-query is to tell the browser how to render things when the screen reaches a certain width.

in your example, you can do something like this:
@media screen and (min-width: 600px)
{
.mobile{ height: 800px;}
}


This tells the browser that whenever the screen width is 600px and higher, to set the height of anything with the class of 'mobile' to 800px

Here is a good resource for you :)
 
Problem: On my cargo site (which isn't live yet) images enlarge infinitely when browser grows. How do I put a max size on them? It's to show off a mobile app and it looks bad when it becomes giant.

I've tried this:

.mobile {
max-height: 800px;
}

It works on desktop, but on mobile it won't shrink properly.

Thanks!


Try using % instead of px. For example:
CSS:
.mobile {
  max-height: 100%;
}
This image will be 100% the height of it's parent element. If you want it to be 100% the height of the total webpage use vh like this:
CSS:
.mobile {
  max-height: 100vh;
}

For this I would recommend setting the maximum size of the image according to the width of the website, so that if your website is long (has a lot of scrolling down), the image would still fit in the screen without having to scroll sideways. If you're going to do this, then use vw instead of vh:
CSS:
.mobile {
  max-width: 100vw;
}


More on this here:




Btw if you don't know any coding, there are some good website builders out there like wix, and many more. Unless you specifically want to code it yourself.



Edit: vh might actually be the height of the screen and not the webpage, I'm not too sure.
 
Last edited:

New Threads

Buy us a coffee!

Back
Top Bottom