Get up to 80 % extra points for free! More info:

Discussion: Menu

In the previous quiz, Online HTML and CSS Quiz, we tested our experience gained from the course.

Activities
Avatar
Vakos
Member
Avatar
Vakos:1/11/2017 11:02

Hello, I have a problem with menu on my page. In attachment is draft how it should look.

When i hover on menu item, it must highlight.

Do you know how can i do that?

 
Reply
1/11/2017 11:02
Avatar
Vakos
Member
Avatar
Vakos:1/11/2017 11:03

Here is attachment

 
Up Reply
1/11/2017 11:03
Avatar
Replies to Vakos
David Capka Hartinger:1/11/2017 11:31

Hi, you have to use the :hover CSS selector and provide which style should be applied to the highlighted item. I suppose you use li elements for menu items, so your CSS will look something like this:

ul.menu li:hover {
        color: red;
        /* other styles... */
}

See this lesson if you need help with coding your menu: https://www.ict.social/…and-entities and the following lesson if you need further help to style it.

Edited 1/11/2017 11:32
Up Reply
1/11/2017 11:31
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
Vakos
Member
Avatar
Replies to David Capka Hartinger
Vakos:1/11/2017 12:00

I know how to make hover, but I don´t know how to make green rectangle. I know how to make with img, but it doesn´t function the hover effect.

I did´t write it, I know ...

 
Up Reply
1/11/2017 12:00
Avatar
Replies to Vakos
David Capka Hartinger:1/11/2017 12:06

You can use the :hover selector with images as well, you just have to use them as backgrounds:

ul.menu li:hover {
        background: url('images/menu_background_hover.png');
        /* other styles... */
}

I can't imagine how you'd add button labels on img elements anyway, the images should be backgrounds:

ul.menu li {
        background: url('images/menu_background.png');
        width: 100px;
        height: 50px;
        /* other styles... */
}
Up Reply
1/11/2017 12:06
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
Vakos
Member
Avatar
Replies to David Capka Hartinger
Vakos:1/11/2017 12:18

Yes, but when I use image it wil only for 1 example, but I need it for changing numbers of item. So, i need to make that green rectangle only with css and no image.

 
Up Reply
1/11/2017 12:18
Avatar
Replies to Vakos
David Capka Hartinger:1/11/2017 13:45

I'm afraid I don't know what you mean. You can use as many images as you want if you mean this, just assign a different class to each item.

If you want to use a pure-css solution, there could be a way of creating a div ellipse above the menu. I'd try to make its background white and the border green. Then disable the top borders. You'll end with that green rounded line which will cover the upper part of the green menu items if positioned correctly. However, the elliptic border won't change the color on hover, only the green background will.

I'd go with images.

Edited 1/11/2017 13:45
Up Reply
1/11/2017 13:45
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
mick
Member
Avatar
mick:11/19/2021 2:52

Thanks for this information!

 
Up Reply
11/19/2021 2:52
Avatar
mick
Member
Avatar
mick:11/22/2021 6:12

Choosing a custom software development company is one of the most important decisions you will make for your business. There are a number of reasons for choosing this route, but the main one is the need for your software to be unique. While readymade solutions may include all the features you need, a custom solution https://mlsdev.com/…augmentation will be tailored specifically to your needs. This means that you will pay more for a customized solution than you would for a readymade version, but the benefits you receive will far outweigh the costs.

 
Up Reply
11/22/2021 6:12
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

9 messages from 9 displayed.