Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does REM make sense on border-radius? [closed]

Tags:

css

I'm using REM units for my project. I would like to use a uniform type of units for all the project. I'm working with a group of developers and I'm trying to find a reason why I would have to apply REM units in all the CSS rules, but sometimes I maybe find it excessive or completely useless.

I would like to know if the following is necessary, benefits or disadvantages:

input{
    border-radius: 0.5rem;
    display: block;
    margin: 0 0 2rem 0;
    min-width: 12rem;
    height: 4rem;
    padding: 0 2rem;
    width: 100%;
}

In this example you can see the border-radius is 5px as the HTML has applied font-size: 62.5% to have an easier method applying the REM units.

like image 249
Daniel Ramirez-Escudero Avatar asked Jun 02 '14 09:06

Daniel Ramirez-Escudero


People also ask

Can you use REM for border-radius?

The border-radius property can accept any valid CSS length unit. That means everything from px , rem , em , ch , vh , vw , and a whole bunch more are fair play. You may specify the value of border-radius in percentages.

Should border-radius be px or REM?

This issue proposes that small values, ranging from 1px to 4px , should be set in px rather than rem as they are most commonly used for things like borders, which should render consistently regardless of any user adjustments to browser font size.

When should I use REM?

Use EM where you have to make more scaling than the root font size. And use REM where you need value according to the root there you can use REM units. This can help with many factors and reduce your code in responsive.

Why we use REM instead of px?

Rem and pixel (px) are two units of measurement frequently used in CSS and HTML to define font size, margin or image size for example. However, the two units have a big difference in terms of web accessibility, because a pixel is not responsive and that's why it'sbetter to use REM.


1 Answers

There is no technical reason not to use the rem unit for border-radius. Neither is never any compelling reason to use the rem unit, for it or otherwise. Using rem is merely something chosen for convenience, as it may help to avoid computing multipliers for the em unit, at the cost of reduced cross-browser functionality.

It is generally safest to use the same unit for different dimensions, and this applies to border-radius, too, when the height and width of the element have been set in rem units. The reason is that this ensures that the shape is preserved if the font size of the root element is changed. If you set the border-radius e.g. in px units and width and height in rem units and the font size of the root element is then set to, say, 32pt, the element box becomes rather large but the border curvature remains small.

like image 117
Jukka K. Korpela Avatar answered Oct 05 '22 06:10

Jukka K. Korpela