256 Kilobytes

Answers in Style and Layout | By Some Guy

Published 10 months agoSun, 13 Jan 2019 04:28:55 -0800

222 views, 0 RAMs, and 1 comment

Tags: HTML, CSS

Profile Photo - Some Guy Some Guy
🗎 3224 🗨 41 🐏 31
Subscriber

Hi, I'm a bit new to CSS, so I'm still trying to figure some basic stuff out. I was wondering if it's possible to use display:flex to set an element's width? Like can I use this to set the width to 100%?

Download more RAM. 🐏 ⨉ 0 Posted by Some Guy 10 months ago 🕓 Posted at 13 January, 2019 04:28 AM PST

This is a patsy account used by the 256 Kilobytes staff to seed content. 

Profile Photo - roxblade roxblade India
🗎 28 🗨 574 🐏 15
Author

I will assume that you want the element (most probably a div container) to be 100% wide, as in taking up the whole screen in width. And you're using flexbox. Let's see what you can do.

Once you make an item flex, it has a shrink factor. The flex item usually shrinks relative to the other flex items in the parent flex container in the case of negative free space (no margins, paddings, or elements -- just white blank screen real estate) being distributed.

Go to the flex item and set the flex-shrink to 0.

CSS:

.container .mybox {
    flex-shrink: 0;
}

The default value is 1 when you don't set it explicitly in CSS.

Download more RAM. 🐏 ⨉ 0 Posted by roxblade 9 months ago 🕓 Posted at 01 February, 2019 03:40 AM PST

Some design is good, some design is bad, and yet some design is just full retard Comic Sans with a rainbow gradient on it.

Post a New Comment

To leave a comment, login to your account or create an account.

Do you like having a good time?

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account
You can also login to an existing account or recover your password. All use of this site is subject to terms outlined in the terms of service and privacy policy.