Aligning list to get 100% width on every row - html

I have the following html and css code:
.catering-cities {
text-align: left;
margin-left: 0 !important;
}
.catering-cities li {
display: block;
float: left;
}
.catering-cities a {
display: block;
background-color: #d6d6d6;
color: #212121;
padding: 15px 10px;
margin: 0 2px 2px 0;
font-size: 11px;
text-transform: uppercase;
}
<ul class="catering-cities clearfix margin_bottom_20">
<li>Augustów</li>
<li>Bartoszyce</li>
<li>Bełchatów</li>
<li>Biała Podlaska</li>
<li>Białystok</li>
<li>Bielsk Podlaski</li>
<li>Brzeg</li>
<li>Bydgoszcz</li>
<li>Chełm</li>
<li>Chrzanów</li>
<li>Ciechanów</li>
<li>Częstochowa</li>
<li>Elbląg</li>
<li>Ełk</li>
<li>Gdańsk</li>
<li>Gdynia</li>
<li>Gliwice</li>
<li>Głogów</li>
<li>Kalisz</li>
<li>Katowice</li>
<li>Kędzierzyn Koźle</li>
<li>Kielce</li>
<li>Kluczbork</li>
<li>Kołobrzeg</li>
<li>Konin</li>
<li>Koszalin</li>
<li>Kraków</li>
<li>Legnica</li>
<li>Lubin</li>
<li>Lublin</li>
</ul>
What I want to achieve is for the ul to fill 100% of the width, the li elements taking a dynamic size, with the same margin inbetween. Something similar to text-align:justify but for ul li elements.
Is this possible to do by changing padding for every element?

You can use flexbox for this together with flex-grow:1 on the li. See snippet below
.catering-cities{
text-align:left;
margin-left:0 !important;
display:flex;
flex-wrap:wrap;
padding-left:0!important;
}
.catering-cities li{
display:block;
flex-grow:1;
}
.catering-cities a{
display:block;
background-color:#d6d6d6;
color:#212121;
padding:15px 10px;
margin:0 2px 2px 0;
font-size:11px;
text-transform:uppercase;
}
<ul class="catering-cities clearfix margin_bottom_20">
<li>Augustów</li>
<li>Bartoszyce</li>
<li>Bełchatów</li>
<li>Biała Podlaska</li>
<li>Białystok</li>
<li>Bielsk Podlaski</li>
<li>Brzeg</li>
<li>Bydgoszcz</li>
<li>Chełm</li>
<li>Chrzanów</li>
<li>Ciechanów</li>
<li>Częstochowa</li>
<li>Elbląg</li>
<li>Ełk</li>
<li>Gdańsk</li>
<li>Gdynia</li>
<li>Gliwice</li>
<li>Głogów</li>
<li>Kalisz</li>
<li>Katowice</li>
<li>Kędzierzyn Koźle</li>
<li>Kielce</li>
<li>Kluczbork</li>
<li>Kołobrzeg</li>
<li>Konin</li>
<li>Koszalin</li>
<li>Kraków</li>
<li>Legnica</li>
<li>Lubin</li>
<li>Lublin</li>
</ul>

Related

Get the desired horizontal margin independently on how the items are in the html

I am trying to apply a CSS rule that fits the next scenarios independently on the layout inside the button.
scenario 1: text
scenario 2: text + icon
scenario 3: icon + text
This is the desired behavior:
For now, I am applying padding to the button, so it works for scenario 1 and then I tried to add a margin to the icon image. However, it is added to the padding and its side becomes bigger than the other.
You can see the issue in the following image.
Can this be achieved with the only CSS?
code
<button class="pzl-button pzl-button-base primary">BUTTON</button>
<button class="pzl-icon-button pzl-button-base primary">BUTTON<img class="pzl-icon-button" src="assets/icon/chevron.svg"></button>
<button class="pzl-icon-button pzl-button-base primary"><img class="pzl-icon-button" src="assets/icon/chevron.svg">BUTTON</button>
css
.pzl-button-base {
margin: 8px;
background: none;
text-decoration: none;
border: 1px solid transparent;
display: inline-block;
padding: 3.5px 16px;
font-family: "Rubik", sans-serif;
font-size: 1rem;
line-height: 1.5;
}
.pzl-button-base.primary{
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.16);
background: #E9B56F;
color: #FAFAFA;
}
.pzl-button-base.primary img {
filter: invert(99%) sepia(35%) saturate(0%) hue-rotate(173deg) brightness(113%) contrast(96%);
height: 1.5em;
}
.button-chevron-inverted {
transform: rotateZ(180deg);
}
.pzl-button-base img {
padding: 0 6px;
}
This is the CSS box model, which might help you to visualise the issue you are having:
Any margin you add to the icon image will come on the 'outside' of the padding property.
I am not 100% sure what you are asking, but if you are trying to add a margin between each of the 3 buttons, then you need to apply the margin property to the buttons, not to the icon images.
does this helps ?
.textbox {
position:relative;
display:inline-block;
width: 8rem;
height: 2rem;
border: 2px solid orange;
margin-left:1rem;
background:orange;
}
.text {
position:relative;
width:100%;
display:inline-block;
text-align:center;
color:white;
margin-top:7px;
}
.leftarrow {
position:relative;
display:inline-block;
float:right;
margin-right:1rem;
}
.rightarrow {
position:relative;
display:inline-block;
float:left;
margin-left:1rem;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" integrity="sha512-HK5fgLBL+xu6dm/Ii3z4xhlSUyZgTT9tuc/hSrtw6uzJOvgRr2a9jyxxT1ely+B+xFAmJKVSTbpM/CuL7qxO8w==" crossorigin="anonymous" />
<div class="textbox"><div class="text">BUTTON</div></div>
<div class="textbox"><div class="text"><i class="fas fa-arrow-right leftarrow"></i>BUTTON</div></div>
<div class="textbox"><div class="text"><i class="fas fa-arrow-left rightarrow"></i>BUTTON</div></div>

Container won't center

This container stubbornly refuses to center. Demo: http://codepen.io/Diego7/pen/KzXgZN
I've tried just about every centering code I can find on the web, to no avail.
Removing width: 90%; from the css aligns the container to the left, even though margin: 0 auto; is telling it to center.
Sorry if this question isn't up to StackOverflow's 'standards', but codingforums.com are down at the moment :(
Thanks heaps!
HTML
<div class="container">
<article>
<header>
<img src="https://softwarereviews.files.wordpress.com/2016/04/bg-header-no-logo.png" width="972px"><br />
<h2>Information</h2>
</header>
<p>There's currently is no information available. Sorry.</p>
<footer>
© 2016
</footer>
</article>
</div>
CSS
##import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700);
body {
font-family: 'Open Sans', sans-serif;
background: #fff;
}
.container {
list-style:none;
margin:0 auto;
width:90%;
padding-top: 20px;
background: #fff;
border-radius: 6px;
box-sizing: container-box;
}
article header h2 {
color: #282828;
font-size: 1.2em;
font-weight: normal;
display:inline;
line-height: 1.3;
}
article p {
font-size: 1em;
display:inline;
line-height: 1.5em;
color: #282828;
max-width: 972px;
}
article footer {
font-size: .9em;
display:inline;
color: #999;
}
a {
color: #2790ae;
text-decoration: none;
outline: none;
}
a:hover {
color: #0f6780;
}
Your .container is already centered: if you change background to red you will see it. And, if you add text-align property its content will be centered too.
.container {
list-style:none;
margin:0 auto;
width:90%;
padding-top: 20px;
border-radius: 6px;
box-sizing: container-box;
text-align:center;
background: red;
}
If you make the width a bit narrower (like 70%), you see that it IS centered.
by the way: " list-style:none;" has no effect whatsoever, and "box-sizing: container-box;" should be "box-sizing: content-box;"
Looks like you're centering the <div class="container">, but it doesn't look like it, because you're looking at the image.
If you want the image to take up the entire <div> element (so that any centering takes effect on both), try something like the following, instead of using an <img> element:
div.container {
background-image: url(https://softwarereviews.files.wordpress.com/2016/04/bg-header-no-logo.png);
}
There are other properties you can use to fiddle with precisely how the image is displayed. You can find more info here.
If you are using container after float tag. It can create problem sometimes. So to avoiding this user <div class="clear"></div>. Also clear class properties would be:
.clear{
clear:both;
margin:0px;
padding:0px;
height:0px;
font-size:0px;
line-height:0px;
float:none;
}
Hope it will be helpful..

aligning right but not breaking the vertical align

I'm still having a lot of trouble with this that it's even difficult to describe the problem now. The yellow text area should be right at the edge (righthand side edge) of the pink div and there should be 30px of margin in between this yellow area div and the other area on the left (contains the green and red areas).
The problem is fixed if I add 'float:right;' in 'home-featured-class-3', but this creates a new problem of shifting the yellow text area div to the top.
How can I make the yellow text div float right but also float vertically in the center? (without adjusting the height/width of anything)
HTML & CSS:
.home-featured-class-3{
width: 630px;
height:auto;
margin:0 0 0 30px;
display: inline-block;
vertical-align: middle;
background:#CF0;
}
.home-featured-class-4{
width:298px;
height:auto;
margin:0 0px 0 0;
border: 1px solid #211c20;
display: inline-block;
vertical-align: middle;
}
.home-featured-class-A{
width:960px;
height:auto;
background:#C3C;
vertical-align:middle;
}
.clear {
clear: both;
}
h6{
font-family:arial,verdana,helvetica,sans-serif;
font-size:18px;
color:#201c1f;
text-decoration:none;
text-transform:uppercase;
font-weight:100;
margin:0;
padding:10px;
background:#DB1D1D;
text-align:center;
border-top:1px solid #211c20;
}
h6 a:link{
color:#201c1f;
text-decoration:none;
}
h6 a:visited{
color:#201c1f;
text-decoration:none;
}
h6 a:hover{
color:#201c1f;
text-decoration:underline;
}
#home-featured-classes-wrap{
width:auto;
height:auto;
margin: 30px 0 0 0;
}
.home-featured-class:hover .products {
text-decoration: underline;
}
.home-featured-class-end{
width:298px;
height:auto;
margin:0 0 0 0;
border: 1px solid #211c20;
float:left;
}
.home-featured-class-end:hover .products {
text-decoration: underline;
}
<div id="home-featured-classes-wrap">
<div class="home-featured-class-A">
<div class="home-featured-class-4"><img name="RP-TEXT" src="http://upload.wikimedia.org/wikipedia/commons/d/de/Color-Green.JPG" width="298" height="148" alt="RP-TEXT" style="background-color: #3366FF" />
<h6 class="products">RP-TEXT</h6>
</div>
<div class="home-featured-class-3">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</div>
<div class="clear"></div>
</div>
</div>
This is your problem (described in CSS comments):
.home-featured-class-3{
width: 630px;
height:auto;
margin:0 0 0 30px; /* Here you set the margin to 30px on the left. */
display: inline-block;
vertical-align: middle;
background:#CF0;
margin: 0; /* Here you set it back to 0 again. Simply remove this line. */
}
Also you’ll have to remove the newlines (or comment them out) above <div class="home-featured-class-3">. The HTML engine creates an additional whitespace character because of this newline leaving you only about 27px of space instead of 30px. You’ll have to remove these newlines in order to be able to set a distance of 30px.
This is what your HTML needs to be:
<div id="home-featured-classes-wrap">
<div class="home-featured-class-A">
<div class="home-featured-class-4">
<img name="RP-TEXT" src="http://upload.wikimedia.org/wikipedia/commons/d/de/Color-Green.JPG" width="298" height="148" alt="RP-TEXT" style="background-color: #3366FF" />
<h6 class="products">RP-TEXT</h6>
</div><!--
--><div class="home-featured-class-3">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</div>
<div class="clear"></div>
</div>
</div>
JSFiddle.

How to display horizontal fraction symbol

I want to imitate fraction numbers like this: http://projectpophealth.org/images/Multi-Provider_Measure_Page.png
I've already seen alternative ways to display fractions: What would be the math symbol for representing a fraction?
But I really like the look and feel of the horizontal symbol. How do I display it in HTML?
I've made up a simple plain html/css solution, you may want to adjust the font to one more suitable by the way.
jsFiddle
<body>
<div class="fraction">
<p class="num">6</p>
<p class="dem">14</p>
</div>
</body>
.fraction{
display: inline-block;
text-align: center;
position:relative;
padding:0 1em;
}
.fraction > .num {
border-bottom: 2px solid #808080;
padding:4px;
margin:0 0 4px 0;
}
.fraction > .dem{
padding: 0;
margin: 0;
}
.fraction > .num:before{
content: "(";
font-size:2em;
height:100%;
position:absolute;
left:0;
top:0.2em;
}
.fraction > .dem:after{
content: ")";
font-size:2em;
height:100%;
position:absolute;
right:0;
top:0.2em;
}
As you commented that its difficult for you to do so, here's the answer. I've used inline elements and I am turning them to a block level so that they render one below another, and for separating them out, I use border-bottom on the first span element.
Rest, for the top offset, I use position: relative; to settle it down... Rest is self explanatory.
Demo
HTML
<div>(<span><span>18</span><span>26</span></span>)</div>
CSS
div {
font-size: 40px;
color: #515151;
}
div > span {
font-size: 18px;
display: inline-block;
}
div > span > span {
display: block;
padding: 0 5px;
position: relative;
top: 5px;
}
div > span > span:first-child {
border-bottom: 1px solid #515151;
color: green;
}
div > span > span:last-child {
color: tomato;
}
I feel that these types of expressions or over complex ones will get cumbersome to do with CSS Only, hence, take a look at Mathjax

Matching web page to word processor with CSS

I'm trying to match the dimensions, margins, text sizes, line height, etc of a web page to those of a word processor (in this case, OpenOffice) so that when you go to print the web page or make a PDF of it, it will look exactly like the document.
So far I've set the height and width to 11in/8.5in, every side margin to 0.79in, and the font is the same size as the document. (That is, if documents use pt.)
So how come it's only taking up half the page??
This site is made to be printed/PDF'd, so it doesn't have to use flexible values.
Thanks!
Here is a link to a sample document, I'll have some code soon
http://i.stack.imgur.com/l2Dl1.png
/*The rules go here*/
#page-container {
background: blue;
margin: 0.79in 0.79in 0.79in 0.79;
width: 7.5in;
height: 11in;
}
.name {
font-size:22pt;
font-weight:bold;
}
.sections {
margin: 10px 0 0 0;
font-weight:bold;
text-decoration:underline;
clear:right;
}
.jobtitles {
font-weight:bold;
}
.leftside {
float:left;
}
.rightside {
float:right;
width:50%;
}
.years {
float: right;
font-weight:bold;
padding-right: 1%;
}
.desc {
width: 760px;
}
ul {
list-style-type: none;
padding:0;
margin:0;
}
#footer {
text-align: center;
font-weight: bold;
}
The only reason its blue is so I can see the container.