Flexbox vs Twitter Bootstrap (or similar framework) [closed] - html

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 7 years ago.
Improve this question
I have recently discovered Flexbox when I was looking for a solution to make divs the same hight, depending on the highest one.
I have read the following page on CSS-tricks.com and it convinced me that flexbox is a very powerful module to learn and use. However, it also made me think about the fact that Twitter Bootstrap (and similar frameworks) offer kind of the same functions (+ of course a lot extra) with their grid systems.
Now, the questions are: What are the pros and cons of flexbox? Is there something one can't do with Flexbox that one can do with a framework like Bootstrap (of course purely talking about the grid system)? Which one is faster when implemented on a website?
I'm guessing when only for the grid system, it's smarter to purely use flexbox, but what if you're already using a framework, is there something flexbox can add?
Are there any reasons to choose flexbox's "grid system" over a framework's?

For a couple of reasons, flexbox is much better than bootstrap:
Bootstrap uses floats to make the grid system, which many would say is not meant for the web, where flex-box does the opposite by staying flexible to the items' size and contents; same difference as using pixels vs em/rem, or like controlling your divs only using margins and padding and never setting a pre-defined size.
Bootstrap, because it uses floats, needs clearfix after each row, or you will get misaligned divs of different height. Flex-box doesn't do that and instead checks for the tallest div in the container and sticks to its height.
The only reason I would go with bootstrap over flex-box is lack of browser support (IE mainly) (die already). And sometimes you get different behavior from Chrome and Safari even though both use the same webkit engine.
Edit:
BTW if the only problem you are facing is the equal height columns, there are quite a few solutions for that:
You can use display: table on the parent, an display: table-cell; on the child. See How to get same height in display:table-cell
You can use absolute positioning on each div:
position: absolute;
top: 0;
bottom: 0;
There is also the jquery/JS solution, and another solution I can't remember at the moment that I'll try to add later.
Edit 2:
Also check http://chriswrightdesign.com/experiments/flexbox-adventures/ & https://scotch.io/tutorials/a-visual-guide-to-css3-flexbox-properties on how flex-box works.
Edit 3:
https://kyusuf.com/post/almost-complete-guide-to-flexbox-without-flexbox
Edit 4:
https://caniuse.com/#feat=flexbox

I havent use Flexbox (I have read about it and seems to be great) but I'm a Bootstrap frontend dev. I suggest you test Flexbox printing pages before making a final decision. You know... Sometimes printing styles are a terrible headache and Bootstrap helps me a lot when I have to design print formats.

I am afraid you missed another article on CSS tricks:
Note: Flexbox layout is most appropriate to the components of an application, and small-scale layouts, while the Grid layout is intended for larger scale layouts.
Does not mean, you may not try, but just think twice. And all depends on desired browser support in the end.

Related

What are the downsides of using relative position in CSS? [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 2 years ago.
Improve this question
I am not very good at CSS, especially when it comes to positioning things on the screen. Is it fine if I eyeball everything and use
position: relative;
with a number of pixels for many of the elements on the page? Is it considered sloppy/unprofessional?
It's totally okay and also it will render fast - possibly even faster than a normal flow-based content. Text flows require the browser to calculate literally every character's position and size and only then are they sure about anything that comes after. It's fairly obvious.
Using absolute or fixed positioning is a lot easier; it's mostly about pixels, no need to pre-render other elements. Relative positioning is a bit trickier, it can depend on earlier contents; on the other hand, this gives it's power.
So no, it's not a sin to use HTML/CSS this way. Check dev console for rendering performance and see how it's different when you're trying. But it should be fast, convenient and supported everywhere.
You can use different kind of scale types like fr, em, vh or % instead of px, it will more helpful when you chancing the size of the browser or using in mobile apps. You should use px in some part, too. Also, you can use position with other values like absolute, fixed etc.
The answer depends on a few factors, but styling the whole website using specifically positioned elements would be considered sloppy.
The reason for this is, that any new content could easily wreck your layout, not to mention having to specifically position everything again for each screen size you wish to support.
You would be much better off using a Flexbox layout (display: flex), or maybe a Grid (display: grid), as these were designed to solve the specific layout issues you might run into.
Even if you feel uncomfortable using CSS, it is worth spending some time getting to know Flexbox and Grid layout, because they can save you a tremendous amount of time and energy on the long run and they really bring back fun to developing frontend layouts.
However... if this is a small static site, and you are fairly sure the content will not change, or will change very rarely and you are comfortable with repositioning a few elements from time to time, you might be better off positioning things manually, if you are not in the position to learn some CSS magic right now.
Also, positioning a few elements here and there using position is completely acceptable.
But for layouts at scale, I'd recommend to go with Flexbox or Grid.

What are the steps to make a HTML design responsive? [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 7 years ago.
Improve this question
I just learned about responsive design. My question is what steps does a HTML designer has to do to make a design responsive?
It appears that a responsive design is all about using #media queries and controlling the flow of elements on the page if it gets resized by setting max-width, min-width and manipulating floating, margins and padding depending on browser window's size.
Is there anything else besides #media query that needs to be done for responsive design?
Responsive Images (different images in HTML for different situations) is an important one.
Few important bits :
Use of srcset attribute for switching between different versions of the same image.
http://responsiveimages.org is a well of resources on this subject.
Use of automation tools for imaging - One of my favorites is Grunt and here is a nice read about it: http://addyosmani.com/blog/generate-multi-resolution-images-for-srcset-with-grunt/
It really makes a lot of difference when user on mobile opens a page with images that are sized for it, less data and well faster loads :)
Tools like Grunt may seem like they take some work to setup but once you start working with it its so easy and fast.
More reading material:
https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/image-optimization
http://blog.cloudfour.com/responsive-hero-images/
Absolutely. There are three main tenants of responsive web design from Ethan Marcotte's original book, Responsive Web Design (abookapart.com/products/responsive-web-design). They are:
1 - Fluid Grids - percentage based widths instead of pixels for your layout/grid. This is arguably even more important than the media query as it allows websites to be fluid and not fixed. So smart phones and tablets come in too many sizes to count, so having a fluid layout makes sure your design can fit nicely at different device widths.
2 - Flexible images - which are basically images that shrink when the browser get smaller. There are plenty of challenges around images in the context of responsive, which is why #Ivan86 smartly recommended using the srcset attribute on the image tag, which I also highly recommend but also maybe wait on that until you're comfortable with the basics. Since you're just starting out, let's keep it simple with 'flexible images' which are images that are set to max-width: 100% with a parent container around them that is % based. This allows the image to shrink as the parent container (div, figure, etc) gets smaller. However, if you do happen to be interested in srcset I posted two articles on this recently: www.richfinelli.com/srcset-part-1, http://www.richfinelli.com/srcset-part-2/ which explain how to use this new attribute.
3 - Media queries - as you said, are used in your css to change the layout based on available browser width.
As I think you're finding out, once you get in to responsive web design you realize there's multiple layers of challenges you can find yourself in. But I recommend buying Ethan Marcotte's book from abookapart.com to get a good jump on it. Very short and actually funny.

Best Way to Move Things Around in CSS? [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 8 years ago.
Improve this question
When I want to move anything (text, images, etc.) in CSS, I find myself using margin-top with ridiculous values like 1000 or even higher. Sometimes I set the position to fixed and I can move the object vertically, but not horizontally.
I guess what I'm trying to say is what is the best way to move things around in CSS? Set the position to fixed? Use "top" instead of "margin-top?" When to use padding. When to use display. etc.
I'm asking this because 1. I'm new to website design and 2. the practice site that I'm making keeps getting messed up (ex. things go behind other things, the site only works in full scree (half screen totally breaks it))
You're question is way too broad. There are so many factors that come into play, it would be impossible to answer. It's kind of like coming onto a car forum and asking "How do I rebuild this car? Every time I unbolt a part of the car, it breaks." There is a lot you have to learn before you can dive in and start creating a site, just like there is a lot you have to learn about cars before you can start rebuilding them. You have to understand how CSS and HTML layout works.
I recommend you start with a basic course, a great one that's recommended often is CodeAcademy, you can try it here: http://www.codecademy.com/tracks/web
By the way, you do not want to use position and/or margin to layout your page. That would be a nightmare to maintain. You have to use a combination of many different elements and properties to properly layout a page. In the beginning it will be very confusing, but if you stick with it, you will learn it.
ok........
1st you need to learn html flow. You can position a lot of elements naturally using div and spans. Css should be used to modify width/ height etc for the majority of elements in this way. You should stick to natural flow as much as possible. Fixed position elements will remain fixed even when scrolling (unless inside div & some css...) so thats not really a solution for every element on your page.
Make a little effort to learn yourself and you will have it, unless you have a specific example of something you cant do, you should focus on tutorials of which there are plenty of.
Concentrate on html 1st and then start css tutorials such as width, dimensions of single elements, then classes of elements (elements with the same style).
Btw just to repeat myself..........position: relative; to keep in the flow, this trys to fit elements in a top to bottom and a little bit horizontal when you ask for it (span/ float: left/right;) enjoy!

What is the logic/philosophy of positioning in CSS? [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 9 years ago.
Improve this question
I am not a web programmer, but we all find ourselves needing to mess around with html, css, and javascript at some point. And every time I do, I find myself hating CSS's guts. This is almost entirely related to positioning. Many things that I think should be easy and straightforward turn out to be very difficult or even (seemingly) impossible.
Take centering something in the user's browser/interface. I recently wanted to do a "Coming Soon…" temporary splash page (cliche, I know), and I wanted a tiny piece of text or image to land right in the middle of the user's browser. Conceptually this couldn't be simpler, and yet to actually achieve this in CSS you have to do all kinds of tricks. I'm not asking how you achieve this. There are several tutorials/examples, including these two excellent ones:
http://css-tricks.com/centering-in-the-unknown/
http://www.dynamicsitesolutions.com/css/center-page-content-horizontally-and-vertically/
What I want to understand is why it is so complex to achieve something so basic? Why can't I just make a div (or whatever) that spans the height and width of the browser, and align something in the middle of that? Why do you have to come up with entire frameworks like Bootstrap (which, in my opinion, are still incomplete and hacky) to do things that should be a part of the philosophy of the implementation?
The people that come up with the CSS standard are much smarter than I am, and there must be a reason for this. What is their logic or philosophy behind how it is implemented? What am I missing? I want to understand, so at least next time I try to implement something I won't fool myself into thinking "This will be easy" when, I assume, there is a reason it can't be.
Because HTML/CSS is limited by its roots: ltr horizontal flow
When we first started making websites, HTML was designed as a simple way to make content flow, like in a magazine or a book. Maybe it would have images or embedded audio, but there was no way to foresee at the time that we would have websites in the millions of lines of code. HTML was designed with horizontal flow, not vertical flow in mind.
There are other examples of this:
It is comparatively difficult to vertically align text to the center or bottom of a page, this requires a lot of unintuitive understanding whereas central alignment on the horizontal plane is a simple text-align='center';
Tables are defined with <tr> table row tags, not <tc> table column tags.
Ever tried making a <DIV>, especially one wrapped inside other divs, the full height of the page (not screen)? It's not as easy as you'd think.
An element with height:100% is not automatically the same height as your browser, only the height of your content. See this example.
Because of the need to maintain backwards compatibility, browsers continue to use rendering engines based on left-to-right, top to bottom rendering. It seems unlikely that an alternative to HTML will take the web by storm any time soon, so we're probably stuck with this paradigm for the foreseeable future.

What are best practices to make layout scalable? [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 5 years ago.
Improve this question
What is technical difference between Fluid vs liquid vs elastic vs Flexible css layouts?
Are these all same or different technically?
Is fluid layout better for both mobiles and computer user?
I think there are only two properties to make fluid layout "em" and "%".
And we already use "em" for font even in fixed width layouts. What are other things we need to do to make site flexible? Which part should be flexible and which would be better as fixed? Or we should make whole thing flexible?
I suggest you to read some articles about this subject. Smashing magazine has a great post about it, to see which one is right for you. They have some definitions about these layouts and I believe they are very accurate:
Fixed:
A fixed website layout has a wrapper
that is a fixed width, and the
components inside it have either
percentage widths or fixed widths. The
important thing is that the container
(wrapper) element is set to not move.
No matter what screen resolution the
visitor has, he or she will see the
same width as other visitors.
Fluid:
In a fluid website layout, also
referred to as a liquid layout, the
majority of the components inside have
percentage widths, and thus adjust to
the user’s screen resolution.
Elastic:
There is a third option when working
with Web page layouts. An elastic
design is sometimes preferred by
designers because it mixes the two
other main layout types. It works by
sizing all elements with em’s. The
quote below explains exactly what an
em is and why it can be beneficial.
The pros and cons in the article are very concise too, with examples and further researching.
If you choose to use "fluidic" layouts, read their article about the subject as well.
They are all pretty much the same. If you want to get really picky, I guess you could say that elastic has a maximum width, whereas fluid might continue to increase in width as long as the window is widened. But generally, they are interchangeble.