Hongmu Notes
Home Language Notes css mouse hover menu appears
Language Notes CSS

css mouse hover menu appears

css mouse hover menu appears

Shows the menu overlay when the user hovers over the image.
鼠标悬停 出现菜单

Use a to wrap the element and the element that will contain the menu link. <figure> <img> <div>
Use the and properties to animate the image on hover, creating a sliding effect. opacityright
Set the property of the element to a negative number. Reset it to when hovering over the parent element to slide through the menu. left<div>width0
Use on and to center the menu item vertically. display: flexflex-direction: columnjustify-content: center<div>

html code


<figure class="hover-menu">
    <img src="https://picsum.photos/id/1060/800/480.jpg"/>
    <div>
        <a href="#">Home</a>
        <a href="#">Pricing</a>
        <a href="#">About</a>
    </div>
</figure>

css code


.hover-menu {
  position: relative;
  overflow: hidden;
  margin: 8px;
  min-width: 340px;
  max-width: 480px;
  max-height: 290px;
  width: 100%;
  background: #000;
  text-align: center;
  box-sizing: border-box;
}

.hover-menu * {
  box-sizing: border-box;
}

.hover-menu img {
  position: relative;
  max-width: 100%;
  top: 0;
  right: 0;
  opacity: 1;
  transition: 0.3s ease-in-out;
}

.hover-menu div {
  position: absolute;
  top: 0;
  left: -120px;
  width: 120px;
  height: 100%;
  padding: 8px 4px;
  background: #000;
  transition: 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hover-menu div a {
  display: block;
  line-height: 2;
  color: #fff;
  text-decoration: none;
  opacity: 0.8;
  padding: 5px 15px;
  position: relative;
  transition: 0.3s ease-in-out;
}

.hover-menu div a:hover {
  text-decoration: underline;
}

.hover-menu:hover img {
  opacity: 0.5;
  right: -120px;
}

.hover-menu:hover div {
  left: 0;
  opacity: 1;
}

 

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

css positioning

css positioning Language Notes CSS

Syntax: position: static | relative | absolute | fixed | center | page | sticky Default value: static Applies to: All elements except the display attribute defined as table-column-group | table-column Inheritance: No Animation: No...
👁 119
css vh and vw adaptive

css vh and vw adaptive Language Notes CSS

In the mobile terminal, REM is used to change the root HTML, and the mobile terminal adaptation is realized through a piece of JS. This article uses pure CSS viewport units to self-adapt. Although the current compatibility is not fully acceptable, it does not prevent you from recognizing the power of vw and vh. The implementation of responsive layout relies on media queries (Media Queries). Select the width size of mainstream devices as breakpoints to target...
👁 356

Recommended reading

Responsive Financial Planning Service Management Website Template 1175

Responsive Financial Planning Service Management Website Template 1175 Practical Collection Yiyou template

An EyouCMS responsive website template designed for financial wealth management service management. Its professional financial design enables effective presentation of wealth management products, investment services, wealth management solutions, and success stories. This template helps financial institutions showcase their brand online and attract investors. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (E...
👁 41
Responsive Financial Planning Service Management Website Template_20240807_101506 1176

Responsive Financial Planning Service Management Website Template_20240807_101506 1176 Practical Collection Yiyou template

An EyouCMS responsive website template designed for financial wealth management service management. Its professional financial design enables effective presentation of wealth management products, investment services, wealth management solutions, and success stories. This template helps financial institutions showcase their brand online and attract investors. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (E...
👁 42
Financial Investment Enterprise Holding Website Template 1177

Financial Investment Enterprise Holding Website Template 1177 Practical Collection Yiyou template

This EyouCMS template is ideal for the financial investment and corporate holding industries, featuring a premium financial design style that effectively showcases investment products, holding projects, corporate strength, and brand image. It enables financial investment groups to present their brand online and attract investors and partners. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | Eyou...
👁 58
Resource website typecho001 template

Resource website typecho001 template Program Notes Typecho

typecho001 template template please do not modify the folder name of this template. The folder name is: typecho001 1.4 Fix the js output problem on the article page 1.3 Fix the error prompt when the plug-in is not installed Optimize the list page code output 1.2 Fix the comment function and add a custom homepage title 1.1 Fix the comment reply asymmetry function Add a separate title setting function on the homepage Add the website favicon.ico icon Add one...
👁 197
Financial Private Equity Enterprise Website Template 1178

Financial Private Equity Enterprise Website Template 1178 Practical Collection Yiyou template

An EyouCMS website template designed specifically for financial private equity firms. Its professional financial design style enables effective presentation of private equity products, investment projects, successful case studies, and corporate strength. This template helps private equity companies showcase their brand online and attract investors and entrepreneurs. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS...
👁 49
Modification of typecho paging style

Modification of typecho paging style Program Notes Typecho

Sir, times have changed! Typecho is currently the most perfect solution, because Baidu can only see the code of fixed thinking. The actual generated HTML code is breathtakingly clean and fully customized, including adding classes to the li element, adding classes to the a element, adding classes to the previous page and next page, and removing the li tags that come with typecho to express more. I can even add some text to the content inside...
👁 516