Does height and width not apply to span?
Span is an inline element. It has no width or height.
You could turn it into a block-level element, then it will accept your dimension directives.
span.product__specfield_8_arrow
{
display: inline-block; /* or block */
}
cant set width and height on div
<div>
elements normally have display:block; applied but you must have somehow changed this to display:inline;
If you didn't do this yourself, it might have been a boilerplate CSS that you used that caused this.
To be able to adjust the width, change the display to:
display:block;
or this will also work and may be preferable if you previously found a need to remove the default block display:
display:inline-block;
Another possibility could be that your div is contained within another div and that parents divs overflow
is set to hidden
.
width and height doesn't seem to work on :before pseudo-element
Note: The ::before
and ::after
pseudo-elements are actually laid display: inline;
by default.
Change the display value to inline-block
for the width & height to take effect while maintaining inline formatting context.
a.infolink::before {
content: '?';
display: inline-block;
background: blue;
color: white;
width: 20px;
height: 20px;
}
http://jsfiddle.net/C7rSa/3/
CSS width and height not working for div with display: inline
display:inline
elements are rendered inline - meaning they do not respect width and height declarations but just 'go with the flow'.
You probably intend to use display:inline-block
instead, making it behave like a block element itself, but follow the parent's flow as an inline element.
The fixed fiddle.
HTML+CSS: 'a' width doesn't work
Question 1: Why?
Because it's by default not a block element.
Question 2: How to fix that?
Make it a block element using display: block;
, or an inline block by display: inline-block;
.
Related Topics
Ionic 4: Changing Ion-Content Background Does Not Work
How to Have Multiple Svg Images in a Single File
Setting Full Height of Angular Components
HTML.Actionlink with a Specified HTML Id
Putting a Border Around Floating Elements
White to Transparent Gradient with Background Image
Site 5X Faster via Mod_Rewrite, But CSS Images Are Broken
Body { Font-Size: 100.01%; } Vs Body { Font-Size: 100%; }
Make Empty Div of One Line Height
CSS Horizontal Navigation Spacing
Font Awesome Icons Are Not Working in Some Browsers
How to Fade in and Out Color of Svg
How to Prevent Fractional Pixels in an Element with Width Set to Auto
Angular: Updating Scope on Hover
Filter: Progid:Dximagetransform.Microsoft.Gradient Is Not Working in Ie7
Linear Fade Out Div, Content and Border (Solid at Top to Transparent at Bottom)