CSS centered list bullet and numbering - html

I have an issue with a website I'm making. There are 2 lists inside of boxes all the text seems to be centered with the bullets out on the far left side of the text. I checked this on my local host and no issues were found there. But when I upload it to my web server the issue happens. I would like the text centered but the bullets closer to the text. Attached is the CSS and HTML for the boxes. Also a link to the file with the issue link (It's live but not linked publicly yet)
.centerDivR {
width: 80%;
height: 500px;
margin: 0 auto;
}
.rulesspace {
width: 4%;
height: 300px;
float: left;
}
.news2 {
width: 46%;
height: 300px;
background-color: rgba(192, 192, 192, 0.6);
float: left;
padding: 4px;
}
.rulesa {
width: 46%;
height: auto;
float: left;
padding: 4px;
}
.rulesb {
width: 46%;
height: auto;
float: left;
padding: 4px;
}
<div style="text-align: center; font size:12pt;"><span class="body">Server Rules||Route Specific Rules
||Local Information
||Train & Destination Tags<br></div></span>
<hr>
<div class="centerDivR">
<div class="rulesa">
<div style="text-align: center;">
<span class="h2"><i>General Rules:</i></span>
<br>
<br>
</div>
<ul>
<li>No Advertiseing other servers</li>
<li>Four Strike Policy
<ol>
<li>1st Warning</li>
<li>2nd Warning</li>
<li>2 Week Ban</li>
<li>Perminate Suspension</li>
</ol>
</li>
<li>Please keep foul language to a minimum</li>
<li>Be considerate of other players</li>
<li>Discussion or distribution of pirated or illegally acquired software is strictly prohibited</li>
</ul>
</div>
<div class="rulesspace"></div>
<div class="rulesb">
<div style="text-align: center;">
<span class="h2"><i>Multiplayer Server Rules:</i></span>
<br>
<br>
</div>
<ul>
<li>No spanwing trains with out dispatcher permission</li>
<li>No flipping switches while DS is on duty with out proper permission</li>
<li>No passing red signals without G or P plates</li>
<li>If a signal has stop indication but contains a G or P plate, stop, and ask DS to proceed at restricted speed</li>
<li>Flipping switches & dropping signals without proper permission while a train is approaching is strictly prohibited.</li>
<li>Hump Yard tags/settings are not to to be changed except by an Administrator.</li>
<li>For the UP and BN trackage, call signals LOWER than clear.
<br>(Clear Varients may be called)</li>
<li>Obey all Speed limits</li>
<li>Do not leave mainline switches open</li>
<li>Special trains (circus trains, OCS trains, etc. may be run only with administrator permission)</li>
<li>Running a track intended for traffic moving opposite your direction may be run ONLY with track warrant accompanying.</li>
<li>If you need to leave with other players on the same trackage, you may step away and hold the main for 15 minutes.
<br>If the limit is reached, your train will be saved and deleted for you to resume later.</li>
</ul>
</b>
</div>
</div>

You might have some mis-matched <div> elements or other markup errors, please valid your HTML and fix them.
If you do set the list items to be center aligned (or inherited from the containers). Try this:
li {
list-style-position: inside;
}
jsFiddle
body {
text-align: center;
}
li {
list-style-position: inside;
}
<ul>
<li>No Advertiseing other servers</li>
<li>Four Strike Policy
<ol>
<li>1st Warning</li>
<li>2nd Warning</li>
<li>2 Week Ban</li>
<li>Perminate Suspension</li>
</ol>
</li>
<li>Please keep foul language to a minimum</li>
<li>Be considerate of other players</li>
<li>Discussion or distribution of pirated or illegally acquired software is strictly prohibited</li>
</ul>

Related

how to make navigation buttons next to each other horizontally

I'm trying to get my navigation buttons to be next to each other, like in this example: https://codepen.io/freeCodeCamp/pen/RKRbwL
Here is my code:
<header id="header">
<img id="header-img" src="https://www.logobee.com/uploads/tesla-logo.png"/>
<nav id="nav-bar">
<ul>
<li>
<a class="nav-link" href="#Features">Features</a>
</li>
<li>
<a class="nav-link" href="#Demo">Demo</a>
</li>
<li>
<a class="nav-link" href="#Pricing">Pricing</a>
</li>
</ul>
</nav>
</header>
<section id="Features">
<h3>EXOSKELETON</h3>
<p>Cybertruck is built with an exterior shell made for ultimate durability and passenger protection. Starting with a nearly impenetrable exoskeleton, every component is designed for superior strength and endurance, from Ultra-Hard 30X Cold-Rolled stainless-steel structural skin to Tesla armor glass.</p>
<h3>ULTRA-HARD 30X COLD-ROLLED STAINLESS STEEL</h3>
<p>If there was something better, we’d use it. Help eliminate dents, damage and long-term corrosion with a smooth monochrome exoskeleton that puts the shell on the outside of the car and provides you and your passengers maximum protection.</p>
<h3>TESLA ARMOR GLASS</h3>
<p>Ultra-strong glass and polymer-layered composite can absorb and redirect impact force for improved performance and damage tolerance.</p>
</section>
<section id="Demo">
<iframe id="video" src="https://www.youtube.com/embed/m7atGkba-Z8" allowfullscreen></iframe>
</section>
<section id="Pricing">
<h3>Single-Motor Cybertruck</h3>
<ul>
<li>$39,900</li>
<li>250+ miles of range</li>
<li>0-60 moh in 6.5 seconds</li>
<li>top speed of 110 mph</li>
</ul>
<h3>Dual-Motor Cybertruck</h3>
<ul>
<li>$49,900</li>
<li>300+ miles of range</li>
<li>0-60 moh in 4.5 seconds</li>
<li>top speed of 120 mph</li>
</ul>
<h3>Tri-Motor Cybertruck</h3>
<ul>
<li>$69,900</li>
<li>500+ miles of range</li>
<li>0-60 moh in 2.9 seconds</li>
<li>top speed of 130 mph</li>
</ul>
</section>
<form id="form" action="https://www.freecodecamp.com/email-submit">
<input id="email" placeholder="Enter your email" type="email" name="email"></input>
<input id="submit" type="submit"></input>
</form>
CSS:
header {
position: fixed;
left: 480px;
top: 0px;
}
#media (max-width: 800px){
position: fixed;
left: 200px;
}
#header-img {
height: 80px;
}
header {
display: flex;
}
li {
display: flex;
}
How do I do this? thank you!
also, I copy and paste my code from codepen into stack overflow but I have to manually space out my code so it is formatted correctly. How do I make it so I can just copy and paste code and have it automatically formatted? I used the code toolbar but it only makes the first line of code formatted.
If you want the nav items to be placed horizontally, you should apply display: flex property to the parent container, i.e, ul in your case.
nav ul {
display: flex;
}
My bad, there should be a space between nav and ul. I've updated my answer. Now it will target only the nav elements

ul bullets not aligning

I've been trying to use
<ul style="text-align:center">
<li> 1794 - born in Berkeley, UK </li>
<li> 1821 - began his training as a doctor </li>
</ul>
Unfortunately, neither bullets and text align correctly, I've tried using divs and it still doesn't work.
This is what is happening:
This is what I want:
Try this simple code snippet
ul {
display: table;
margin: 0 auto;
}
<ul class="list">
<li class="list-item">1794 - born in Berkeley, UK</li>
<li class="list-item">1821 - began his training as a doctor</li>
</ul>
If you want to keep the list centered in the page/parent element, but have the list items aligned to the left, wrap the ul tag in a block container that has a text-align: center;, and set the ul as a display: inline-block; and text-align: left;.
Did you want this? https://codepen.io/anon/pen/WdyVPJ
Code
HTML
<ul class="list">
<li class="list-item">1794 - born in Berkeley, UK</li>
<li class="list-item">1821 - began his training as a doctor</li>
</ul>
CSS
ul {
text-align: left;
}
li {
text-align: center;
}
That's because you have to center the internal elements (<li>) while aligning to the left the external element (<ul>)
<ul style="text-align:left">
<li style="text-align:center"> 1794 - born in Berkeley, UK </li>
<li style="text-align:center"> 1821 - began his training as a doctor </li>
</ul>
Check the result here: https://jsfiddle.net/L1xmkof6/

Responsive div with image aligned 100% to text

I am trying to get an image aligned right of some text/lists while having the image still be 100% in height and within the div. So far I've come close but the image is always overlapping the bottom of the div. Here's an example of what I'm trying to achieve:
Here's the code I've come up with so far, I've been using inline CSS but once I've figured it out it'll be in a separate CSS file. Any help is really appreciated, been trying to figure this out for days!
<div style="background: #000; width: 90%; color: #fff; margin: 0 auto; text-align:left; border: 1px solid #95403c;">
<p>
<img style="float: right; margin: 1px 1px 1px 1px; width: 355px;" src="" />
<div align="center">
<h1>Gold (proper style coming soon)</h1><br />
<clear>
<u>All Edited Videos Include:</u>
<ul style="display: inline-block; text-align: left;">
<li>60-90 Minute Interview Documentary</li>
<ul><li>B-Roll Footage</li>
<li>Incorporation of personal video clips (up to 15) and photographs (up to 125)</li>
<li>Interview Transcript</li></ul>
<li>1-2 Minute Individual Clips of Family Members </li>
<li>Up to 5 individuals will share a favorite memory with or express their love for the subject </li>
<li>5-10 Minute Prized Possession</li>
<li>The subject will share and describe their most prized possession</li>
<li>Behind The Scenes Photographs</li></ul>
</ul>
<clear>
<div style=" display: inline-block; vertical-align: top;">
<u>You Will Receive:</u>
<ul style="display: inline-block; text-align: left;">
<li>USB flash drive with all edited video files,<br /> pictures, and interview transcript</li>
<li>15 DVDs</li>
<ul><li>Customized printed DVDs</li>
<li>Customized menu and chapters</li>
<li>Hard cases with customized insert</li></ul>
</ul></div>
<div style="display: inline-block; vertical-align: top;">
<u>All Edited Videos Include:</u>
<ul style="display: inline-block; text-align: left;">
<li>Customized Titles</li>
<li>Customized Graphics</li>
<li>Music</li>
<li>Sound Design</li>
<li>Color Correction</li>
</ul>
</div>
<clear>
<br style="clear: both;" /></p>
</div>

HTML/CSS a <div> won't go below another one

I have this page where all the div's seem to work and then all of the sudden my last one breaks. I have two divs in my CSS, one being centeredRight and one centeredLeft. They are lined up down the page. But my last div on the left seems to get pushed to the right.
Here is my CSS.
.centeredlistleft {
width: 300px;
margin: 0 auto;
text-align: left;
border: 2px solid;
float: left;
margin-bottom: 25px;
padding-right: 10px;
}
.centeredlistright {
width: 300px;
margin: 0 auto;
text-align: left;
border: 2px solid;
float: right;
margin-bottom: 25px;
padding-right: 10px;
}
.body {
margin: 0 auto;
padding: 0;
text-align: center;
color: purple;
background-color: pink;
}
And here is my HTML.
<div id="sandrcontainer" class="body" style="width:700px">
<div id="onsieforbaby" class="centeredlistleft" >
<h3> Onesie for Baby </h3>
<ul>
<li>
Price
<ul>
<li>$10.00</li>
</ul>
</li>
<li>
Description
<ul>
<li>It's a boy onesie for a new baby boy. Carter onesies are used. Can ask for specific size. Can also make one for girls using pink.</li>
</ul>
</li>
</ul>
</div>
<div id="largetennistowel" class="centeredlistright">
<h3> Large Tennis Towel </h3>
<ul>
<li>
Price
<ul>
<li>$14.00</li>
</ul>
</li>
<li>
Size
<ul>
<li>16 x 26 (Inches)</li>
</ul>
</li>
<li>
Description
<ul>
<li> Cotton fleece. Very soft. Washes Well. Can be personalized. Check out the photo gallery for examples. Ask seller what color towels are available at time of order.</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="sandrcontainer2" class="body" style="width:700px">
<div id="largegolftowel" class="centeredlistleft">
<h3> Large Golf Towel </h3>
<ul>
<li>
Price
<ul>
<li>$14.00</li>
</ul>
</li>
<li>
Size
<ul>
<li>16 x 26 (Inches)</li>
</ul>
</li>
<li>
Description
<ul>
<li> Golf towel. Elegant. Large white towel. Cotton fleece. Very soft. Can be personalized. Check out photo gallery for examples. Ask seller what color towels are avaiable at time of order. This towel has a grommet and can be hung on golf bags. Could also make this on fingertipe towel for guest bath or on linen towel for that elegant look.</li>
</ul>
</li>
</ul>
</div>
<div id="terrysmalltowel" class="centeredlistright">
<h3> Terry Small Towel </h3>
<ul>
<li>
Price
<ul>
<li>$11.00</li>
</ul>
</li>
<li>
Size
<ul>
<li>11 x 18 (Inches)</li>
</ul>
</li>
<li>
Description
<ul>
<li> With fringe. Made of 100% cotton loop terry. Can be personalized. Check out photo gallery for examples. Ask seller what color towels are avaiable at time of order.</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="sandrcontainer3" class="body" style="width:700px">
<div id="contactmerands" class="centeredlistleft" >
<p> Please make sure to send me an email before any orders. I may not have the color towel you want but can always order more </p>
</div>
<div id="smallfingertip" class="centeredlistright" >
<h3> Small Fintertip Holiday Towel </h3>
<ul>
<li>
Price
<ul>
<li>$11.00</li>
</ul>
</li>
<li>
Size
<ul>
<li>11 x 18 (Inches)</li>
</ul>
</li>
<li>
Description
<ul>
<li> Terry small towel with decorated cat for xmas. Made of 100% cotton loop terry. Can be personalized. Check out photo gallery for examples. Ask seller what color towels are available at time of order.</li>
</ul>
</li>
</ul>
</div>
</div>
TLDR - ctrl f for "Contactmerands" and please explain to me why this box is getting pushed to the bottom RIGHT of the large golf towel box. It should appear under the large golf towel box just like the rest of the divs.
If you would like to see what I mean you can go to my school web portal where I have the page posted HERE.
When an element is floated, it is essentially removed from the flow of the document. Thus, when a parent element's children are all floated, the parent collapses upon itself as it doesn't have any defined dimensions.
To solve this, you could set either overflow:hidden or overflow:auto on the parent elements. This essentially forces it to contain the children elements, therefore preventing it from collapsing.
Add the following CSS and your problem is solved:
#sandrcontainer,
#sandrcontainer2,
#sandrcontainer3 {
overflow: hidden;
}
Sometimes changing the overflow property will conflict with existing CSS. You could alternatively use the pseudo element clearfix:
.clearfix:after {
content: '';
clear: both;
display: table;
}
You must clear your floats in order to achieve the desired effect.
I suggest using a valid clearfix for this.
You need to declare this in CSS:
.clearfix:after {
clear:both;
content:".";
display:block;
font-size:0;
height:0;
visibility:hidden;
}
.clearfix { display:block; }
Now wrap all your elements that should float next to each other in a DIV and apply the clearfix class:
<div class="clearfix">
<!-- put your divs here //-->
</div>
<!--put your last div here //-->

CSS scaling a border-image

I am seeking some assistance creating a border that scales with different screen sizes/devices. I've attached both the desired outcome, html/css I've written so far and a live page to preview the results so far.
Issues/Questions:
The border is set using pixels, and I'm concerned that it won't scale to the proper proportions on different devices/browsers.
The corners don't match very well.
Is there a better way to achieve the desired border so as to scale proportionally and achieve the desired corner formatting? Maybe a vector image?
I'm close to achieving a match, but there must be a (more simple? better?) way to re-create that type of border. Many thanks for looking this over and for your input.
Regards,
Zephyr
EDIT/UPDATE:
I've also tried using background-image: and creating six .png files, one for each corner with a solid white background, and one each for the top/bottom and left/right sides of the "border". Again, it's close but the images don't always line up correctly.
There must be a way to do this, perhaps in a svg image that scales itself depending on the size of the section its in, but that is way beyond my talents.
Thanks for considering the issue!
The desired formatting:
See the desired formatting here
The current results & html/css:
See the border-image: results here
See the background-image: results here
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>
EP Layout Test
</title>
<style type="text/css">
.ep {
background-image: url(ep_border_top_left-w.png), url(ep_border_top_right-w.png),url(ep_border_bottom_right-w.png), url(ep_border_bottom_left-w.png), url(ep_border_vertical.png), url(ep_border_vertical.png), url(ep_border_horizontal.png), url(ep_border_horizontal.png);
background-position: top left, top right, bottom right, bottom left, left, right, top, bottom;
background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, repeat-y, repeat-y, repeat-x, repeat-x;
width: 70%;
margin-left: auto;
margin-right: auto;
}
.ep_content {
padding: 2.5em;
}
.ep_title {
background-color: black;
padding: 0.5em 0em;
color: white;
}
p {
text-align:left;
}
</style>
</head>
<body>
<p>
This is some regular text.
</p>
<div class="ep">
<div class="ep_content">
<h3 class="ep_title">
SINGLE-ENGINE FAILURE/FLAMEOUT
</h3>
<p>
Symptoms:
</p>
<ol>
<li>
TGT, Ng, torque, and Np on malfunctioning engine decreasing toward zero.
</li>
<li>
NO. 1 ENG OUT or NO. 2 ENG OUT warning light illuminated.
</li>
</ol>
<p>
Corrective Action:
</p>
<ol>
<li class="boldface">
Nr - MAINTAIN.
</li>
<li class="boldface">
CONTGCY PWR - ON.
</li>
<li class="boldface">
Altitude/Airspeed - AS REQUIRED.
</li>
<li class="boldface">
Fuel/stores - JETTISON AS REQUIRED.
</li>
<li class="boldface">
ENG Anti-ice - AS REQUIRED.
</li>
<li>
Analyze.
</li>
</ol>
<p>
If no indication of mechanical malfunction or engine fire:
</p>
<ol start="7">
<li>
Perform Engine Restart Procedure.
</li>
</ol>
<p>
If Engine Restart Procedure is not to be performed:
</p>
<ol start="8">
<li>
Conduct EMER ENG SHUTDOWN.
</li>
<li>
LAND AS SOON AS PRACTICABLE.
</li>
</ol>
</div>
</div>
<p>
This is some regular text.
</p>
</body>
</html>
Original code using border-image
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>
EP Layout Test
</title>
<style type="text/css">
.ep {
border-width: 32px 31px 32px 31px;
border-image: url(chapter_3_background-small.png) 32 31 32 31 round round;
border-color: #cccccc;
border-style: solid;
width: 70%;
margin-left: auto;
margin-right: auto;
}
.ep_title{
background-color: black;
padding: 0.5em 0em;
color: white;
}
p {
text-align:left;
}
</style>
</head>
<body>
<p>
This is some regular text.
</p>
<div class="ep">
<h3 class="ep_title">
SINGLE-ENGINE FAILURE/FLAMEOUT
</h3>
<p>
Symptoms:
</p>
<ol>
<li>
TGT, Ng, torque, and Np on malfunctioning engine decreasing toward zero.
</li>
<li>
NO. 1 ENG OUT or NO. 2 ENG OUT warning light illuminated.
</li>
</ol>
<p>
Corrective Action:
</p>
<ol>
<li class="boldface">
Nr - MAINTAIN.
</li>
<li class="boldface">
CONTGCY PWR - ON.
</li>
<li class="boldface">
Altitude/Airspeed - AS REQUIRED.
</li>
<li class="boldface">
Fuel/stores - JETTISON AS REQUIRED.
</li>
<li class="boldface">
ENG Anti-ice - AS REQUIRED.
</li>
<li>
Analyze.
</li>
</ol>
<p>
If no indication of mechanical malfunction or engine fire:
</p>
<ol start="7">
<li>
Perform Engine Restart Procedure.
</li>
</ol>
<p>
If Engine Restart Procedure is not to be performed:
</p>
<ol start="8">
<li>
Conduct EMER ENG SHUTDOWN.
</li>
<li>
LAND AS SOON AS PRACTICABLE.
</li>
</ol>
</div>
<p>
This is some regular text.
</p>
</body>
</html>
Could this solve your problem? http://jsfiddle.net/65nhJ/
<div id="borderImage" >
<div class="ep" >Text</div>
</div>
CSS:
#borderImage{
/* background-image: url(chapter_3_background-small.png); */ /*Your border image*/
background-color: red; /*removeme*/
width: 70%;
margin: 0 auto;
padding: 20px; /*Border size*/
}
.ep {
background-color: white;
}
Instead of use a real border-image use a fake parent div with the background of your image (repeated) and then set to white the background to don't show background (border) of the parent div.
I you need more help just comment.
SOLUTION!
As suggested by José Cabo (above) I stumbled across an example of the repeating-linear-gradient property here and coupled with a solid white background for the content div, I have exactly what I was hoping to achieve - all with only a few lines of CSS.
No messing with images and corners and pixel widths... grrr.
Simple, elegant, scalable - beautiful!
I have more testing to do using other browsers, but it works in Safari, and that's a giant leap toward what I'm trying to achieve.
See the solution here
Regards,
Zephyr
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>
EP Layout Test
</title>
<style type="text/css" >
.ep {
padding: 1.5em;
background: -moz-repeating-linear-gradient(top left -45deg, black, black 1.1em, white 1em, white 2em);
background: -ms-repeating-linear-gradient(top left -45deg, black, black 1.1em, white 1em, white 2em);
background: -o-repeating-linear-gradient(top left -45deg, black, black 1.1em, white 1em, white 2em);
background: -webkit-repeating-linear-gradient(-45deg, black, black 1.1em, white 1em, white 2em);
width: 70%;
margin-left: auto;
margin-right: auto;
}
.ep_content {
padding: .5em;
background: white;
}
.ep_title {
background-color: black;
padding: 0.5em 0em;
color: white;
}
p {
text-align:left;
}
</style>
</head>
<body>
<p>
This is some regular text.
</p>
<div class="ep">
<div class="ep_content">
<h3 class="ep_title">
SINGLE-ENGINE FAILURE/FLAMEOUT
</h3>
<p>
Symptoms:
</p>
<ol>
<li>
TGT, Ng, torque, and Np on malfunctioning engine decreasing toward zero.
</li>
<li>
NO. 1 ENG OUT or NO. 2 ENG OUT warning light illuminated.
</li>
</ol>
<p>
Corrective Action:
</p>
<ol>
<li class="boldface">
Nr - MAINTAIN.
</li>
<li class="boldface">
CONTGCY PWR - ON.
</li>
<li class="boldface">
Altitude/Airspeed - AS REQUIRED.
</li>
<li class="boldface">
Fuel/stores - JETTISON AS REQUIRED.
</li>
<li class="boldface">
ENG Anti-ice - AS REQUIRED.
</li>
<li>
Analyze.
</li>
</ol>
<p>
If no indication of mechanical malfunction or engine fire:
</p>
<ol start="7">
<li>
Perform Engine Restart Procedure.
</li>
</ol>
<p>
If Engine Restart Procedure is not to be performed:
</p>
<ol start="8">
<li>
Conduct EMER ENG SHUTDOWN.
</li>
<li>
LAND AS SOON AS PRACTICABLE.
</li>
</ol>
</div>
</div>
<p>
This is some regular text.
</p>
</body>