How can I make a list-style-image scale with the list's font size, when we can't use glyph fonts?
I would approach solving this problem using a pseudo element before each li
Here is the markup
ul { list-style: none;}
li { position: relative;}
li:before { /* The desired width gets defined in two places: The element width, and background size. The height only gets defined once, in background size. */ position: absolute; display: block; content: '\2022'; /* bullet point, for screen readers */ text-indent: -999999px; /* move the bullet point out of sight */ left: -.75em; width: .4em; /* desired width of the image */ height: 1em; /* unrelated to image height; this is so it gets snipped */ background-repeat: no-repeat; background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI4cHgiIGhlaWdodD0iMTRweCIgdmlld0JveD0iMCAwIDggMTQiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDggMTQiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxwYXRoIGZpbGw9IiM2NjY2NjYiIGQ9Ik0wLjM3LDEyLjYzOGw1LjcyNi01LjU2NUwwLjUzMSwxLjM0N0MwLjI1MiwxLjA1OSwwLjI2MSwwLjYwMSwwLjU0NywwLjMyMWMwLjI4OS0wLjI3OSwwLjc0Ni0wLjI3MiwxLjAyNiwwLjAxNmw2LjA2Miw2LjI0YzAsMC4wMDIsMC4wMDYsMC4wMDQsMC4wMDgsMC4wMDZjMC4wNjgsMC4wNywwLjExOSwwLjE1NiwwLjE1NiwwLjI0NEM3LjkwMiw3LjA4OCw3Ljg0Niw3LjM5OSw3LjYzMSw3LjYxYy0wLjAwMiwwLjAwNC0wLjAwNiwwLjAwNC0wLjAxLDAuMDA2bC02LjIzOCw2LjA2M2MtMC4xNDMsMC4xNDEtMC4zMzEsMC4yMDktMC41MTQsMC4yMDVjLTAuMTg3LTAuMDA2LTAuMzcyLTAuMDc4LTAuNTExLTAuMjIxQzAuMDc2LDEzLjM3NiwwLjA4MywxMi45MTksMC4zNywxMi42MzgiLz48L3N2Zz4='); background-size: .4em .7em; background-position: 0 .3em;}
.small-list { font-size: 85%;}
.large-list { font-size: 150%;}
<ul class="small-list"> <li>The goal is to make the chevron smaller for this list</li> <li>Specifically, just slightly smaller than capital letters, as stated.</li> <li>Nomas matas</li> <li>Roris dedit</li></ul> <ul class="large-list"> <li>And larger for this list</li> <li>Multiline list item<br>for testing</li> <li>Nomas matas</li> <li>Roris dedit</li></ul>
CSS list-style-image size
Try using a <img />
tag instead of setting the list-style-image
property. Setting the width
and height
properties in CSS will crop the image, but if you use a <img />
tag, the image can be re-sized using the value specified by width
and height
(CSS) properties or (HTML) attributes for that <img />
element.
How to set image size same as container font-size
I believe you accomplish it by setting image height relative to the font height and setting the image width to auto like so:
.svgicon img, .svgicon svg { height: 1em; width: auto;}
p, span { font-size: 16px;}
<p>text <span class="icon svgicon"><img class="custom" src="img.jpeg" /></span></p><p>text <span class="icon svgicon"><svg>...</svg></span></p>
Bullet points to small with ::before / I tried :display none and use ::marker but wont work with my theme
What you're looking for is the line-height
CSS property.
After you've made your font-size
adjustments, change your line-height
as desired.
How do I make the text bigger when a list also has an href?
You should use a CSS file whenever possible. You could also use a style tag. But the following in your html file.
<style>
ul li,
ul li a {
color:black;
font-size:30px;
}
</style>
Incorrect sizing for the icon-font build with Glyphs and exported with FontSquirrel
My mistake was to create glyphs with setting of "units per em" equal to 1000. After changing the value, already existing glyphs do not update automatically, you should press the button next to the setting.
How can I make an svg scale with its parent container?
To specify the coordinates within the SVG image independently of the scaled size of the image, use the viewBox
attribute on the SVG element to define what the bounding box of the image is in the coordinate system of the image, and use the width
and height
attributes to define what the width or height are with respect to the containing page.
For instance, if you have the following:
<svg>
<polygon fill=red stroke-width=0
points="0,10 20,10 10,0" />
</svg>
It will render as a 10px by 20px triangle:
Now, if you set only the width and height, that will change the size of the SVG element, but not scale the triangle:
<svg width=100 height=50>
<polygon fill=red stroke-width=0
points="0,10 20,10 10,0" />
</svg>
If you set the view box, that causes it to transform the image such that the given box (in the coordinate system of the image) is scaled up to fit within the given width and height (in the coordinate system of the page). For instance, to scale up the triangle to be 100px by 50px:
<svg width=100 height=50 viewBox="0 0 20 10">
<polygon fill=red stroke-width=0
points="0,10 20,10 10,0" />
</svg>
If you want to scale it up to the width of the HTML viewport:
<svg width="100%" viewBox="0 0 20 10">
<polygon fill=red stroke-width=0
points="0,10 20,10 10,0" />
</svg>
Note that by default, the aspect ratio is preserved. So if you specify that the element should have a width of 100%, but a height of 50px, it will actually only scale up to the height of 50px (unless you have a very narrow window):
<svg width="100%" height="50px" viewBox="0 0 20 10">
<polygon fill=red stroke-width=0
points="0,10 20,10 10,0" />
</svg>
If you actually want it to stretch horizontally, disable aspect ratio preservation with preserveAspectRatio=none
:
<svg width="100%" height="50px" viewBox="0 0 20 10" preserveAspectRatio="none">
<polygon fill=red stroke-width=0
points="0,10 20,10 10,0" />
</svg>
(note that while in my examples I use syntax that works for HTML embedding, to include the examples as an image in StackOverflow I am instead embedding within another SVG, so I need to use valid XML syntax)
make font size smaller when post title exceeds a limit
Firstly, this will probably be awkward as you should be building responsive sites. Your text should readjust based on the screen reading the website, and if you are trying to define changes to make the text fit on one line you could be tweaking this over and over again.
I advise that you design around this and customise your layout rather than trying to change size based on text length, over and over again.
However, you could do something as follows within PHP/CSS.
Check the strlen
on the get_title
function. If the strlen
is more than a specified amount (say 20) you'd add a class, otherwise ignore it. Then, you'd style that class responsively based on how you wanted to change the font.
You'd need to edit your theme to replace the Title with the following:
<?php
$title = get_the_title();
if (strlen($title) >= 20) {
<h1 class="longer-text-modifier">
} else {
<h1>
}
<?= $title; ?>
</h1>
With your CSS being
.longer-text-modifier {
font-size: 16px; // or em or rem
}
Edit: This could also be done on the fly with JavaScript.
When making a list, how can I make the multi-line sentence be even with the start of the other sentences?
Here is one way you can solve this.
ul { list-style: none;}ul li { position: relative; padding-left: 20px;}ul li:before { position: absolute; top: 0; left: 0; content: '✓'; color: #4ab847; font-weight: bold; line-height: 1.5em;}
<ul> <li>Tehniskā palīdzība 24/7</li> <li>Neierobežots norbraukums</li> <li>Maiņas automašīna satiksmes negadījuma vai zādzības gadījumā Maiņas automašīna satiksmes negadījuma vai zādzības gadījumā Maiņas automašīna satiksmes negadījuma vai zādzības gadījumā</li> <li>Civiltiesiskā atbildība</li> <li>Apdrošināšana avāriju un tehnisku bojājumu gadījumiem</li> <li>Apdrošināšana zādzību gadījumā</li></ul>
Related Topics
Change Color of Svg Spritesheet Sprite with CSS
HTML Line with a Downward Arrow
Display Two Object Same Real Distance (E.G. Inches) Apart Across Different Browers/Screen Sizes
Display:Flex Not Working in Chrome
What Is The Default Width of an HTML Table Cell <Td>
Div Moves When I Put Text in It
Keyframes Delay Between Iterations
How to Check Parent Element Has Specific Class in Sass
Resize Font Depending on String Length
Do I Still Need to Include Type="Value" in HTML5
Border Collapse Differences in Ff and Webkit
How to Select Multiple Ids in CSS
How to Apply Different CSS Styles to 2 Elements with The Same Class Name
CSS: How to Make Left Float Div to Adjust Height Dynamically
How to Support Inline Comments in Postcss
How to Customize Only with CSS for HTML5 Input Range Slider-Vertical