Questions tagged [css]
CSS (Cascading Style Sheets) is a representation style sheet language used for describing the look and formatting of HTML (HyperText Markup Language), XML (Extensible Markup Language) documents and SVG elements including (but not limited to) colors, layout, fonts, and animations. It also describes how elements should be rendered on screen, on paper, in speech, or on other media.
54,853
questions
4228
votes
33
answers
3.6m
views
Is there a CSS parent selector?
How do I select the <li> element that is a direct parent of the anchor element?
As an example, my CSS would be something like this:
li < a.active {
property: value;
}
Obviously there are ...
1291
votes
41
answers
498k
views
How to remove the space between inline/inline-block elements?
There will be a 4 pixel wide space between these span elements:
span {
display: inline-block;
width: 100px;
background-color: palevioletred;
}
<p>
<span> Foo </span>
&...
980
votes
14
answers
1.8m
views
Flexbox: center horizontally and vertically
How to center div horizontally, and vertically within the container using flexbox. In below example, I want each number below each other (in rows), which are centered horizontally.
.flex-container ...
5105
votes
128
answers
4.9m
views
How can I horizontally center an element?
How can I horizontally center a <div> within another <div> using CSS?
<div id="outer">
<div id="inner">Foo foo</div>
</div>
575
votes
7
answers
188k
views
Why don't flex items shrink past content size?
I have 4 flexbox columns and everything works fine, but when I add some text to a column and set it to a big font size, it is making the column wider than it should be due to the flex property.
I ...
1861
votes
33
answers
1.1m
views
Is there a "previous sibling" selector?
The plus sign selector (+) is for selecting the next adjacent sibling.
Is there an equivalent for the previous sibling?
1110
votes
5
answers
433k
views
In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?
Consider the main axis and cross axis of a flex container:
Source: W3C
To align flex items along the main axis there is one property:
justify-content
To align flex items along the cross axis there ...
1668
votes
50
answers
1.9m
views
How can I vertically center a div element for all browsers using CSS?
I want to center a div vertically with CSS. I don't want tables or JavaScript, but only pure CSS. I found some solutions, but all of them are missing Internet Explorer 6 support.
<body>
<...
247
votes
5
answers
80k
views
CSS-only masonry layout
I need to implement a masonry layout. However, for a number of reasons I don't want to use JavaScript to do it.
Parameters:
All elements have the same width
Elements have a height that cannot be ...
741
votes
10
answers
236k
views
Image inside div has extra space below the image
Why in the following code the height of the div is bigger than the height of the img ? There is a gap below the image, but it doesn't seems to be a padding/margin.
What is the gap or extra space ...
151
votes
9
answers
48k
views
Can I combine :nth-child() or :nth-of-type() with an arbitrary selector?
Is there a way to select every nth child that matches (or does not match) an arbitrary selector? For example, I want to select every odd table row, but within a subset of the rows:
table.myClass tr....
1079
votes
30
answers
2.0m
views
How can I vertically align elements in a div?
I have a div with two images and an h1. All of them need to be vertically aligned within the div, next to each other. One of the images needs to be absolute positioned within the div.
What is the CSS ...
1215
votes
30
answers
2.6m
views
How can I center text (horizontally and vertically) inside a div block?
I have a div set to display:block (90px height and width), and I have some text inside.
I need the text to be aligned in the center both vertically and horizontally.
I have tried text-align:center, ...
1081
votes
10
answers
710k
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 ...
229
votes
7
answers
276k
views
Why doesnt percentage height work in HTML/CSS?
I am trying to set a <div> to a certain percentage height in CSS, but it just remains the same size as the content inside it. When I remove <!DOCTYTPE html> however, it works; the <div&...