Click here to Skip to main content
15,903,201 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello, friends:

I am designing navigation bar using list and I have set a certain background image for the li tag and I've wrote a tag inside li tag as the code below.

The problem is that the text in a tag showed above the image in li, I want it to be showed under the image, how can I do it?

What I have tried:

PHP
<li style="background: ('images/nav-bar/home.png') no-repeat center 0px;">
                                                    <a href="index.php">
                                                        Home
                                                    </a>
                                                </li>

                                                <li style="background: ('images/nav-bar/products.png') no-repeat center 0px">
                                                    <a href="services.php">
                                                        Services
                                                    </a>
                                                </li>

                                                <li style="background: ('images/nav-bar/downloads.png') no-repeat center 0px">
                                                    <a href="index.php">
                                                        Downloads
                                                    </a>
                                                </li>

                                                <li style="background: ('images/nav-bar/about.png') no-repeat center 0px">
                                                    <a href="index.php">
                                                        About Us
                                                    </a>
                                                </li>

                                                <li style="background: ('images/nav-bar/faqs.png') no-repeat center 0px">
                                                    <a href="index.php">
                                                        Faqs
                                                    </a>
                                                </li>

                                                <li style="background: ('images/nav-bar/contact.png') no-repeat center 0px">
                                                    <a href="contact.php">
                                                        Contact Us
                                                    </a>
                                                </li>


and this is the css:
PHP
ul#nav{
    direction:rtl;
    float:left;
}
ul#nav li{
    display:inline-block;
    height:85px;
}

ul#nav li a:hover{
    color:orange;
    text-align:center;
}

ul#nav li a{
    vertical-align:basline;
    font-size:18px;
    font-weight:bold;
    display:block;
}
Posted
Updated 20-Dec-16 3:47am
v4
Comments
Kornfeld Eliyahu Peter 22-Jun-16 8:45am    
What is it: background: removed('images/nav-bar/products.png')?
Richard Deeming 22-Jun-16 11:12am    
The site sometimes swallows certain CSS constructs. I'm guessing that was originally:
background: url('...');
Ma'd Saeed 22-Jun-16 15:52pm    
it's an error, the site automatically added 'remove' word on my code!
Ma'd Saeed 22-Jun-16 15:52pm    
it's an error, the site automatically added 'remove' word on my code!
Richard Deeming 22-Jun-16 11:17am    
The background image is precisely that - it puts an image in the background of the element. The content of the element will always appear above the background of the element, and there's no way to change that.

Are you trying to use the images to replace the text?

1 solution

Add below styles your style.

CSS
ul#nav li {
    width: 85px;
    margin: 0 auto;
    position: relative;
}


CSS
ul#nav li a {
    position: absolute;
    right: 0;
    left: 0;
    width: 100%;
    bottom: 0;
    text-align: center;
}


It will appear text below image.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900