html horizontal two-element lists - html

I have a list of names that I'm displaying in one cell of a table with a space between each. For formatting reasons I want to avoid putting each in its own table cell. I now want to put a small avatar or photo above each name. I can obviously do one person as <img src="photo.gif"><br>name... but using or obviously creates a vertical not horizontal list. I can no longer use spaces obviously.
Is there any horizontal version of a <br> tag that I could use to space out the people?
Alternatively, is there a way to do this with css? I found some references to placing images side by side using float left, however, the text is not in a tag. Using multiple span tags does not seem so appealing. Here is img code I found.
.left{
float:left;
margin:0;
padding:0;
}

Using the following CSS:
.horizontalList li {
display: inline;
margin-left: 10px;
margin-right: 10px;
}
You can make an element which usually displays as a block i.e. <LI> , <DIV> , etc to display inline. The margins are just added to give a little space between each element.
So for example,
<UL class="horizontalList">
<LI><img src="img1.png"/>Person 1</LI>
<LI><img src="img2.png"/>Person 2</LI>
<LI><img src="img3.png"/>Person 3</LI>
<LI><img src="img4.png"/>Person 4</LI>
</UL>
Just as well, you can alter the style of the images to display as a block rather than inline, so you can add this CSS to do that:
.horizontalList img {
display: block;
margin-bottom: 10px;
}

Related

Multiple li tags

Is there a way to display multiple li tags of HTML in a single line as shown below. Basically we need to display the first few li elements in a single line and rest in a list as shown below link. Thanks.
See CSS and positionning possibilities. You've to change regular comportements of li in layout (default one)by setting new rules. i.e.: using float CSS properties but they're many mny ways to set and place elements in the way you like in your page.
When using bootstrap you can even use grid predefine layout fitting what you want(so for example fill each grid cell with one li) but that seems more complex and make you write more i think.
Yes it is possible.
I created an example pen for you.
HTML
<ul>
<li>
<div>
<span>Item1</span>
<span>Item2</span>
<span>Item3</span>
<div>
</li>
<li>item 4</li>
</ul>
CSS
ul{
list-style-type:none;
display:flex;
justify-content:space-between;
flex-grow:1;
}
ul li{
display: inline-block;
}
Place your image files instead of the span tags. Make sure you add display:inline-block; property to them and give proper widths and heights to the image files.
The magic behind this is flexbox

'Enter' between <li> tag and <a> tag breaks the layout

I've go an html from frontend developers. Part of the menu looks like the following:
<ul id="subNav">
<li>Menu item 1</li>
<li>Menu item 2</li>
</ul>
I had to add some programming tags, and to make code easier to read I've changed it to:
<ul id="subNav">
<li>
Menu item 1
</li>
<li>
Menu item 2
</li>
</ul>
After my change, the menu is broken. Space between elements are smaller. I have compared computed css and they look the same. Why is that? Why 'enter' between <li> and <a> break the layout?
Tested on Chrome.
EDIT:
Fiddle: http://jsfiddle.net/bqyjL6rf/
When you ran the tags together, you eliminate the white space inserted in inline elements. Breaking them apart, as in your second example, puts that white space back in and that is why your layout has changed.
Just as words you type into a paragraph, inline elements also have their white space between elements.
The spaces between these blocks are just like spaces between words. That's not to say the spec couldn't be updated to say that spaces between inline-block elements should be nothing, but I'm fairly certain that is a huge can of worms that is unlikely to ever happen.
To adjust that
set display:inline-block instead of using display:inline
li {
font-family: SlateProBk;
font-size: .6rem;
line-height: .6rem;
text-transform: uppercase;
opacity: 0.75;
-webkit-opacity: 0.75;
margin: 0;
padding: 0;
display: inline-block;
list-style-type: none;
-webkit-font-smoothing: subpixel-antialiased;
}
Check this fiddle
http://jsfiddle.net/bqyjL6rf/1/

img float:left - margin elements on the right

As you can see in this example http://jsfiddle.net/PCcj8/ I'd like to add some margin to my unordered list. However, I'm not able to move that list because of that img float. How can I achieve it? Please consider there can be different images of different widths.
Wrap your <ul> tag in a <span> tag <span> tag like this:
<span>
<ul>
<li>test</li>
<li>test</li>
</ul>
</span>
and then style the span like this:
span{
display: inline-block;
margin-left: 20px;
}
New style definition for that UL:
ul {
margin: 0 0 0 -5px; display: inline-block;
}
It leaves a LITTLE bit of an indent for the line item, and it will move along with any images you may put to the side.
Here's a forked fiddle: enter link description here

What CSS styling to give more spaces between hyperlinks

I have an ASP.NET application with contains a list of hyperlinks. After each hyperlink, there is a br tag that puts each hyperlink on their own line. I want to increase the spacing between each line. I don't want to add another br trag since that does not provide the control I am looking for. I have tried different CSS styling without any change. What CSS styling do I use to accomplish this?
For the hyperlinks you could use display:block; and margin-bottom:[some value] style/CSS properties, you wouldn't need to have your BR elements, and you would gain much more control.
You could add margin or padding to top of your BR tags eg.
br { margin:10px 0; }
If that isn't feasible, then make your hyperlinks block level and add margin or padding to top of them eg.
a { display:block; margin:10px 0; }
Using the latter method you don't require the BR tags anymore.
Remove the <br /> elements and instead give those anchor elements a display:block property.
Then use padding-top or padding-bottom or margin-top or margin-bottom to increase the space between.
i think what you are looking for is line-height:
http://www.w3.org/TR/WCAG20-TECHS/C21.html
even though this might be the better/'nicer' solution:
<ul id="mylinklist">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
<li>Link 5</li>
</ul>
and this style:
ul#mylinklist{
list-style-type: none;
margin: 0;
padding: 0;
}
ul#mylinklist li{
margin-bottom: 10px;
}
use margin-top or margin-bottom
a{
margin-bottom: 1em;
}

Ordered list - html : How to make point(ol{style-list:disc;}) position in midde height of image?

Ordered list - html : How to make point(ol{style-list:disc;}) position in midde height of image?
Example where point located in bottom of image and not in middle:
The code of example
<ol style="style-list:disc;">
<li><img src="https://t2.gstatic.com/images?q=tbn:MezWc3ku_XBiwM:http://www.whereisacar.com/images/cars/bill-gates-car.jpg"></li>
<li><img src="https://t0.gstatic.com/images?q=tbn:98OwBE0-icyCNM:http://www.comparecheapinsurance.com/car-insurance/images/car-insurance-policy.jpg"></li>
</ol>
My parpose to move image or point position that will looks that point in middle of image height.
Edit: I am looking for the way without use background point image, if this option exist
First of all, make it ul instead of ol, like this:
<ul class="images">
<li><img...
<li><img...
</ul>
Then add this CSS:
ul.images img {
vertical-align: middle;
}
Turn off the bullet in the CSS and instead use an image as a CSS property on the <li>:
ol {
list-style: none;
}
li {
background: url(bullet.gif) no-repeat 0 50%;
}
Also, since you're just displaying bullets, it would make more sense to use an unordered list <ul>.