Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I position list in <div>?

Tags:

html

css

I have a <div> and it has a image in background. Now I want to put a list into that Div so how can I position that in

http://i.stack.imgur.com/VWmB2.png

you can See in above picture I have background and a list but I am not able to position it.

My Code

<div id="footer">
        <div id="footer-content">
            <div id="footer-list">
                <ul>

                    <li><a href="#home">Home</a></li>
                    <li><a href="#news">Blog</a></li>
                    <li><a href="#contact">About FF</a></li>
                    <li><a href="#about">FAQ</a></li>
                    <li><a href="#about">How To Play</a></li>
                    <li><a href="#about">Terms of Use</a></li>
                    <li><a href="#about">Privacy Policy</a></li>

                </ul>
           </div>
        </div>
    </div>

css--

#footer-list ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    margin-left: 500px;
    margin-top:  100px;
}
#footer
{
    background-image: url(/img/footer.png);
    height: 140px; 
    width: 1820px; 
    background-repeat: no-repeat;
    left:0px;
    bottom: 0px;
}

The problem with my css is when I am giving the 'margin-top:100px' to ul it goes down but the background pic is also goes down.

So how can I position the list in div?

like image 856
Bhavik Joshi Avatar asked Apr 25 '15 08:04

Bhavik Joshi


People also ask

Can you put a list in a div?

Yes, you can.

How do I change the position of text in a div?

Using CSS, you can center text in a div in multiple ways. The most common way is to use the text-align property to center text horizontally. Another way is to use the line-height and vertical-align properties. The last way exclusively applies to flex items and requires the justify-content and align-items properties.

How do I move a list to the right in HTML?

To make a right-aligned version of the list, only three changes need to occur. First, set the "UL" "text-align" to "right". Second, change the left "background-position" from "0" to "100%" - which makes the image align up with the right edge. And finally change "padding-left" to "padding-right".

How do I move UL to left in HTML?

You can add padding: 0 to the ul element to force it to stick to the left border of the parent nav element.


1 Answers

I think this is what you want. When u use <ul> u can't use <div> inside that. So checkout this

#footer-content ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    margin-left: 500px;
}
#footer-content ul li {
     display: inline;
}
#footer
{
    background-image: url('http://i.stack.imgur.com/VWmB2.png');
    height: 140px; 
    width: 1820px; 
    background-size: 1820px 140px;
    background-repeat: no-repeat;
    left:0px;
    bottom: 0px;
    padding-top:50px;
}
<div id="footer">
        <div id="footer-content">
            <ul>
                    <li><a href="#home">Home</a></li>
                    <li><a href="#news">Blog</a></li>
                    <li><a href="#contact">About FF</a></li>
                    <li><a href="#about">FAQ</a></li>
                    <li><a href="#about">How To Play</a></li>
                    <li><a href="#about">Terms of Use</a></li>
                    <li><a href="#about">Privacy Policy</a></li>
            </ul>
        </div>
    </div>
like image 145
Harshana Samaranayake Avatar answered Oct 02 '22 01:10

Harshana Samaranayake