Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force a list to be vertical using html css

Tags:

html

css

I have a list i want to add to a <div>. Each listitem contains a <div> which in turn contain an image and a text string. The list must be vertical. I ve tried putting display:block for the <ul> with width:100% but the list is flowing left to right horizontally. How do I make the list vertical?

like image 804
kavita deshpande Avatar asked Jul 15 '11 05:07

kavita deshpande


People also ask

How do I make a vertical list in CSS?

(This is an old question, I know) There are two scenarios here: 1) if you want the text alignment to be center, then use text-align: center on the ul ; but if you want the list itself to be centered on the screen with the text still left aligned, then define a width or max-width property and add margin-left: auto; ...

How do I make a horizontal list vertical in HTML?

By default, the HTML <ul> list will be rendered vertically with one list item on top of another. When you need to create a list that expands horizontally, you need to add the display:inline style to the <li> elements of the list.

How do I change a vertical list to horizontal in CSS?

Use Padding property Horizontally: Padding property is used to set the element align to Horizontally by using left and right padding. Output: Use Padding property Vertically: Padding property is used to set the element align to Vertically by using top and bottom padding.

How do you make a vertical box in HTML?

To make a vertical line, use border-left or border-right property. The height property is used to set the height of border (vertical line) element. Position property is used to set the position of vertical line. Example 1: It creates a vertical line using border-left, height and position property.


2 Answers

Try putting display: block in the <li> tags instead of the <ul>

like image 197
Paul Avatar answered Sep 23 '22 23:09

Paul


I would add this to the LI's CSS

.list-item {     float: left;     clear: left; } 
like image 25
Joe Avatar answered Sep 22 '22 23:09

Joe