How to add a mouse hover effect to the homepage Banner?

Calendar 👁️ 57

As an experienced website operations expert, I fully understand your pursuit of website visual effects and user experience.The homepage banner acts as the 'face' of the website, its design and interaction directly affect the first impression of visitors.Today, let's delve into how to add an attractive hover effect to the home page banner in AnQiCMS, making your website more vibrant.

Use CSS creatively to make the home page Banner dynamic

To implement the mouse hover effect of the home page Banner in Anqi CMS, it's actually not as complex as you imagine.AnQiCMS's powerful template system and content management capabilities provide us with great flexibility.The core idea is to use CSS's:hoverA pseudo-class, combined with HTML structure and AnQiCMS Banner data calling mechanism, can easily create an eye-catching interactive experience.

Let's sort out the source and structure of the Banner content in Anqi CMS.In AnQiCMS backend, you can configure Banner images in the "Website Navigation Settings", or upload Banner images for specific categories or pages in "Category Management" and "Page Management".These banner data will eventually be called to the front-end page through specific template tags.For the homepage, we usually use{% bannerList %}This tag is used to retrieve Banner data.

Prepare the Banner's HTML skeleton and data call.

In the AnQiCMS template system, the homepage template file is usually located in/templatethe directory under the theme directory you have selected, for exampleindex/index.htmlOr it is directly.index.html. We need to build the Banner's HTML structure in this file and use{% bannerList %}tags to loop out Banner content.

{% bannerList %}The tag can flexibly retrieve the Banner list you have configured in the background. You can specifytypeparameters to call Banners from different groups (such astype="首页轮播"), you can also use the default group. When looping through Banner data, each Banner item will provideLogo(Image address),Link(Link address),Alt(Image Alt Text) andTitle(Title) and other fields, these are the basis for constructing our HTML structure.

This is a basic HTML structure example, showing how to use{% bannerList %}The tag is used to render the Banner and adds the necessary CSS classes to each Banner item for subsequent style control:

<div class="main-banner-container">
    {% bannerList banners with type="default" %} {# 假设调用默认分组的Banner #}
        {% for item in banners %}
            <a href="{{item.Link}}" target="_blank" class="banner-item">
                <img src="{{item.Logo}}" alt="{{item.Alt | default:item.Title}}" class="banner-image">
                <div class="banner-overlay">
                    <h3 class="banner-title">{{item.Title}}</h3>
                    {% if item.Description %}
                        <p class="banner-description">{{item.Description}}</p>
                    {% endif %}
                </div>
            </a>
        {% endfor %}
    {% endbannerList %}
</div>

In this structure:

  • main-banner-containerIt is the overall container of the Banner.
  • banner-itemIs each individual Banner item, it is a<a>label that wraps the image and description.
  • banner-imageIs the Banner image.
  • banner-overlayIs a pop-up, we can place the title and description here, and display or change the style when the mouse hovers.

Inject CSS magic to create a hover effect.

Now we have the HTML skeleton, the next step is to inject CSS styles into it to achieve dynamic effects on mouse hover. These CSS style files are usually stored in/public/static/In the directory of related themes. You can find and edit these CSS files in the "Template Design" feature in the background, or upload them directly via FTP/SFTP.

We can design a common hover effect: when the mouse moves over the Banner, the image slightly enlarges, and at the same time, the text on the floating layer becomes opaque from semi-transparent, and moves slightly upward, creating a sense of information emerging.

/* Banner容器的基本样式 */
.main-banner-container {
    width: 100%;
    overflow: hidden; /* 确保图片放大时不会溢出容器 */
    position: relative;
    /* 如果是轮播,这里可能还需要轮播插件的额外样式 */
}

/* 每个Banner项的样式 */
.banner-item {
    display: block; /* 让a标签充满整个空间 */
    position: relative;
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    /* 其他布局样式,例如如果是多图并排,这里需要flex或grid布局 */
}

/* Banner图片样式 */
.banner-image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease-in-out; /* 平滑过渡效果 */
}

/* Banner浮层样式,默认隐藏或半透明 */
.banner-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0)); /* 渐变背景 */
    color: #fff;
    opacity: 0; /* 默认不透明度为0,隐藏 */
    transform: translateY(100%); /* 默认向下移动100%,完全隐藏 */
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out; /* 平滑过渡 */
    box-sizing: border-box;
}

.banner-overlay .banner-title {
    font-size: 24px;
    margin-bottom: 10px;
}

.banner-overlay .banner-description {
    font-size: 16px;
    line-height: 1.5;
}

/* 鼠标悬停时的效果 */
.banner-item:hover .banner-image {
    transform: scale(1.05); /* 图片放大5% */
}

.banner-item:hover .banner-overlay {
    opacity: 1; /* 浮层完全不透明 */
    transform: translateY(0); /* 浮层向上移动到原位 */
}

Add this CSS code to your theme stylesheet (for examplestyle.cssormain.css), save and refresh the page, and you will see the dynamic effect of the Banner when the mouse hovers over it.

Improve and optimize

You can adjust it according to your actual needs to make the effect more perfect:

  • Image processing:If the size of the Banner image is not uniform, you can consider usingobject-fit: cover;Properties or upload images with consistent dimensions in the background to ensure visual consistency.
  • Multi-layer animation:You can set up forbanner-titleandbanner-descriptionSet different ones separately.transition-delayLet them have a sense of disorder when emerging, adding fun to the animation.
  • Compatibility:Always pay attention to the browser compatibility of CSS properties and add browser prefixes when necessary.

By following these steps, your security CMS homepage banner will have an attractive mouse hover effect.This not only enhances the visual appeal of the website, but also strengthens the user interaction experience through dynamic feedback, allowing visitors to better feel the professionalism and vitality of the website.


Frequently Asked Questions (FAQ)

Q1: My Banner image sizes are not uniform, how can I ensure that the hover effect is coordinated and not distorted?

A1:The inconsistency in image size is indeed a common problem affecting visual coordination.In AnQiCMS, you can start from two aspects.Firstly, the most direct method is to ensure that the size ratio and resolution of all Banner images are roughly the same when uploading them on the backend (for example, 16:9 or 4:3).Secondly, at the CSS level, you can useobject-fitProperty to control the display method of the image within the container. For example,object-fit: cover;It will fill the entire container with the image, cropping the extra parts to maintain the image's integrity;object-fit: contain;It will scale the image proportionally to fit the container completely, leaving possible blank spaces. Combiningoverflow: hidden;You can effectively manage the cropping area when the image is zoomed.

Q2: Besides changing the style, can I display more information on hover, such as a button or additional explanation?

A2:Of course, we providebanner-overlayThe structure is designed for this. You canbanner-overlayAdd any HTML elements, such as a Call-to-Action (CTA) button<a>Additional text paragraph<p>Even small icons and so on. In CSS, you can control the default visibility of these elements (for exampledisplay: none;oropacity: 0;),then.banner-item:hover .banner-overlayrules, setting them to visible or adjusting transparency. Combine differenttransitionThe effect can make this additional information appear more vivid.

Q3: Do I have an easier way to add hover effects to the Banner without directly modifying the template file?

A3:In most cases, the most flexible way to add this interactive effect is to directly edit the template file and CSS.This is because the design philosophy of AnQiCMS is highly customizable, building the front-end through template tags and static resources.If modifying files is inconvenient for you, consider the following 'compromise' solutions: first, find or purchase an AnQiCMS theme with the hover effect you need, so you can change the theme directly without manually modifying the code;The second is to use the "Content Materials" or "Custom Parameters" function in the AnQiCMS background to store some HTML/CSS fragments as reusable content, and then reference them in the template through simple tags, but this still requires an understanding of the template structure, and the ability to implement complex effects is limited.The most recommended is still familiar with template file editing, which will bring you the greatest freedom.

Related articles

Does the `bannerList` tag support random display of an item from the Banner list?

In modern website operation, Banner (banner advertisement) serves as a visual focus, which is crucial for attracting users' attention and conveying core information.Flexibly manage and display Banner, especially when it is necessary to bring users a sense of novelty, random display has become a highly关注的 demand.

2025-11-06

How to integrate third-party ad code in the home page Banner?

As an experienced website operations expert, I know that how to efficiently use website space for monetization and promotion is a focus for many enterprises and content operators in an increasingly competitive online environment.AnQiCMS is an efficient and flexible content management system, its powerful customizability provides a solid foundation for us to achieve these operational goals.Today, let's delve into a common operation requirement: how to integrate third-party advertising code into the AnQiCMS homepage banner.

2025-11-06

The `bannerList` tag provides additional filters to handle the images or text of the Banner?

As an experienced website operation expert, I am happy to delve into the function of the `bannerList` tag in Anqi CMS and answer questions about its filters.When building a visually appealing and content-effective website, the Banner (banner ad or carousel) is undoubtedly the key element in attracting users' attention.Safe CMS provides a convenient `bannerList` tag, but its functionality is far more than just simple content calls.--- ### Flexible use of the `bannerList` tag in AnQi CMS

2025-11-06

How can I use the `type` parameter to display multiple different styled Banner areas on the homepage?

As an expert in website operation who is well-versed in AnQi CMS, I fully understand your need to display a diversified Banner area on the homepage.A vibrant and rich homepage is often the key to attracting users and enhancing brand image.AnQi CMS is born to meet such needs with its powerful flexibility and customizability.Today, let's delve into how to巧妙运用 `type` parameter skillfully in Anqi CMS to achieve diversified display of the home page Banner.### Display of various banners on the AnQi CMS homepage

2025-11-06

The `bannerList` tag affects the page loading speed when fetching Banner data?

As an experienced website operations expert, I fully understand your concern about website loading speed.In today's internet environment where user experience is paramount, even milliseconds of delay can affect user retention and conversion.AnQiCMS (AnQiCMS) is a modern content management system developed based on the Go language, which has always put high performance and high concurrency as the core goal from the very beginning.Therefore, when you ask whether the "bannerList" tag affects the page loading speed when fetching Banner data?When this question is asked

2025-11-06

How to set the display priority or weight of the Banner in the Anqi CMS backend?

As a senior operation expert of Anqi CMS, I am well aware of the crucial role of website banners in attracting user attention and conveying core information.The display order of the banner, which seems like a minor detail, actually directly affects the effective delivery of marketing content and user experience.In Anqi CMS, although there is no direct numeric input box labeled "priority" or "weight" to control the arrangement of banners, the system provides a set of intuitive and flexible management methods that allow you to easily control the display order of banners.

2025-11-06

Does the `bannerList` tag support displaying different Banners based on user permissions?

In website operation, how to provide customized content experience according to different user groups has always been the key to improving user stickiness and conversion rate.For Banner elements with strong visual impact and direct information delivery, the need for differentiated display is particularly common.As an experienced user and operations expert of AnQiCMS, I will discuss whether the `bannerList` tag supports displaying different Banners based on user permissions?This topic, combined with the functional features of AnQiCMS, is deeply analyzed for everyone.### One

2025-11-06

How to implement the Banner image carousel effect in Anqi CMS template?

As an experienced website operations expert, I am happy to provide you with a detailed explanation of how to implement the banner image carousel effect in AnQiCMS (AnQiCMS) templates.AnQi CMS, with its flexible template mechanism and powerful content management capabilities, provides an excellent foundation for us to implement such functions.--- ## In AnQiCMS Template, Implement the Banner Image Carousel Effect Guide In today's web design, the Banner image carousel (Carousel) is almost a standard feature for every corporate website, portal website

2025-11-06