All Questions
455 questions
1085
votes
10
answers
714k
views
What is a clearfix?
Recently I was looking through some website's code, and saw that every <div> had a class clearfix.
After a quick Google search, I learned that it is for IE6 sometimes, but what actually is a ...
564
votes
29
answers
552k
views
How to center an element horizontally and vertically
I am trying to center my tabs content vertically, but when I add the CSS style display:inline-flex, the horizontal text-align disappears.
How can I make both text alignments x and y for each of my ...
369
votes
6
answers
444k
views
Fill remaining vertical space with CSS using display:flex
In a 3-row layout:
the top row should be sized according to its contents
the bottom row should have a fixed height in pixels
the middle row should expand to fill the container
The problem is that as ...
1073
votes
15
answers
325k
views
How do you keep parents of floated elements from collapsing? [duplicate]
Although elements like <div>s normally grow to fit their contents, using the float property can cause a startling problem for CSS newbies: If floated elements have non-floated parent elements, ...
791
votes
29
answers
542k
views
Using jQuery to center a DIV on the screen
How do I go about setting a <div> in the center of the screen using jQuery?
50
votes
6
answers
56k
views
CSS: Width in percentage and Borders
I've defined widths of the containers in percentage. I'd like to add a border (3px on right side of a width), since container width is in % while the border width is in px, how can I adjust the width ...
758
votes
14
answers
361k
views
What's the difference between align-content and align-items?
What is the difference between align-items and align-content?
526
votes
13
answers
1.1m
views
How can I expand floated child div's height to parent's height?
I have the page structure as:
<div class="parent">
<div class="child-left floatLeft">
</div>
<div class="child-right floatLeft">
</div>
</div>
...
214
votes
6
answers
145k
views
Truncating long strings with CSS: feasible yet?
Is there any good way of truncating text with plain HTML and CSS, so that dynamic content can fit in a fixed-width-and-height layout?
I've been truncating server-side by logical width (i.e. a blindly-...
550
votes
16
answers
947k
views
How to set Bullet colors in UL/LI html lists via CSS without using any images or span tags [duplicate]
Imagine a simple unsorted list with some <li> items. Now, I have defined the bullets to be square shaped via list-style:square; However, if I set the color of the <li> items with color: #...
201
votes
7
answers
756k
views
Fixed Table Cell Width
A lot of people still use tables to layout controls, data etc. - one example of this is the popular jqGrid. However, there is some magic happening that I cant seem to fathom (its tables for crying out ...
154
votes
26
answers
135k
views
How to prevent long words from breaking my div?
Ever since switching from TABLE-layout to DIV-layout, one common problem remains:
PROBLEM: you fill your DIV with dynamic text and inevitably there is a super-long word that extends over the edge of ...
62
votes
3
answers
172k
views
Transform: translate(-50%, -50%)
When working with hero images or full screen anything, I typically see text or images with the following bit of CSS:
.item {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
What is ...
358
votes
13
answers
675k
views
Scrolling a flexbox with overflowing content
Here's the code I'm using to achieve the above layout:
.header {
height: 50px;
}
.body {
position: absolute;
top: 50px;
right: 0;
bottom: 0;
left: 0;
display: flex;
}
...
197
votes
6
answers
273k
views
Position absolute and overflow hidden
We have two DIVs, one embedded in the other. If the outer DIV is not positioned absolute then the inner DIV, which is positioned absolute, does not obey the overflow hidden of the outer DIV.
#...