Which unit should be used in web design [closed] - css

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am trying to design new website but I have some problems. I am using 13inch laptop when I look at the site in my computers browser everything is fine but when I look at the bigger screen div's are shown smaller etc. Which units should I use for div's width, height and the margins ? I have already try px em and know I have made it something like this.
.tBackground{
margin-left:10%;
margin-top: -200px;
margin-bottom:auto;
margin-right:auto;
height: 30%;
width: 110%;
background: rgba(80, 78, 78, 0.75);
overflow:auto;
}
with this css it is normal at bigger screen but in my 13inch laptop it is very big it doesn't fit the screen

There's not simply one unit to be used in web design. The reason that they're all there is for variation. It entirely depends on what you want:
px - Does not scale down for mobile devices
em - Does scale down for mobile devices
percent - Takes up a set amount of the screen
It depends entirely on what is trying to be accomplished. However, these are just basic differences. If you would like to read more about them, you can visit this website (which also includes pt).
Also, you can read the answers to this StackOverflow question: Why em instead of px?

Related

Why don't my grid columns layout correctly in Firefox? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
so on this website http://kimandydev.com/
the spacing is weird on only the 4th row.
Everything is gridded out perfectly on Chrome and Safari, but on in Firefox.
I used Advanced Custom Fields to feed the content just FYI.
Can someone inspect it on firefox and somehow figure out what is causing it?
Thank you
The problem is that some of your images aren't the same aspect ratio, and Firefox considers the partial-pixel height difference when it lays out the floats, so they don't clear.
Be sure that all your images are exactly 1000x1500.
You could also force image sizes at each breakpoint using media queries:
#media (min-width: 940px) { /* or whatever it is */
.front-img {
height: 330px;
}
}

Should we use max-width 100% to all images in a website? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
If I set img {max-width: 100%) to make a default responsive feature to all images in a website. Is it a good practice? Should I do that?
Yes, it is a good practice but only if you implement it properly through inheritance and proper CSS naming to avoid convoluted HTML and CSS.
Having a default max-width:100% for images is a good thing as it set a standard for your website that no images should be larger than the window or the container in which it resides unless specified.
This way, you can give exceptions to specific images that should be allowed a size larger than the window or for different screen sizes using size specific rules.
It is better to make use of width and max-width. If the width of the image exceeds max-width, it will be constrained to the max value.
For example, consider the below CSS
img { width: 100%; max-width: 512px; }
If the width of the image exceeds more than 512px, then the image width is restriacted to 512px.

What is the most efficient way to have background images of different sizes in a responsive design website? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am building a responsive website. This website needs a lot of background images (both vector and raster formats).
I want to optimize the website for loading speed but not decrease picture quality.
My understanding is that I should have different versions for the same picture so that for small window devices the user automatically downloads the correct smallest file size.
My question is: What is the best way to deal with this problem? Do I need to use media queries? how to use them such that different browsers actually don't download unnecessary data?
Well, another post here on SO discussed if an unused css image url(''); is downloaded by the browser even if no element matches the rule. And it's been tested and established that on all major browsers, the images won't be downloaded unless an element actually matches the selector.
Post: Are unused CSS images downloaded?
It means that, if you define media queries for your styles, only the images inside rules that match the specific viewport will be downloaded.
In the following example, if you're in a device which is 480px wide or less, don't worry because large.jpg won't be downloaded.
#media (max-width: 480px) {
#myDiv {
background-image: url('small.jpg');
}
}
#media (min-width: 481px) {
#myDiv {
background-image: url('large.jpg');
}
}
Just reminding that this is a behavior left up to the browsers, so they can change anytime they want.

Image too wide for viewport in responsive flexbox website [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am planning to redesign my site using the Flexible Box Layout Module to make it responsive since it seems to be the winning layout method for responsive sites.
But what happens if an image in one of the boxes are wider than the viewport? Can I automatically scale down the size of the image if the image is too wide for the viewport?
I haven't been able to find solid info on this topic. This may be a basic or bad question, I am not sure.
Yes, as following:
img {
max-width: 100%;
height: auto;
width: auto\9; /* ie8 */
}
(although I'm not sure if necessary, since mobile devices scale down images themselves)

Non-responsive site will not resize to fit mobile browsers [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm trying to take a template that was designed to be responsive and make it "unresponsive."
http://myhurlburt.com/NEW/bowling.php
The width of the page is set to 960px. When I view it on an iPad or iPhone, you have to scroll to the side to see the entire page. Do you know what in my CSS is causing that? I would like the entire site to "fit" into a browser so the user does not have to scroll to the side.
It's a big job to change an unresponsive site to a responsive one.
But you could try something like this to get started.. .wraper currently has it's width set to 960px.
.wraper{
width:100%;
max-width:960px;
}
use % for width, height and other margins. Use media queries also. If not, do zoom:1(2,3 or something);
Start by scaling the website with min/max widths and additionally use percentages instead of px.

Resources