当前位置:首页 > 市场动态

自建站_自建网站加载转圈

发布时间:2026-07-12 10:26:06 来源:新闻中心 浏览次数:9858

一、自建站自站加载转纯CSS实现旋转转圈效果

HTML结构

自建站_自建网站加载转圈

创建一个覆盖全屏的建网`div`作为加载容器,并在其中放置旋转的自建站自站加载转元素(如`div`或`span`)。

自建站_自建网站加载转圈

```html

```

自建站_自建网站加载转圈

CSS样式

使用`@keyframes`定义旋转动画,建网并通过`animation`属性应用到加载元素上。自建站自站加载转

```css

.load-container {

position: fixed;

top: 0;

left: 0;

width: 100%;

height: 100%;

background-color: f1f1ea;

z-index: 9999;

display: flex;

justify-content: center;

align-items: center;

}

.loader {

width: 50px;

height: 50px;

border-radius: 50%;

background-color: 666;

box-shadow: 0 2px 0 666;

animation: loop 1s infinite linear;

-webkit-animation: loop 1s infinite linear;

}

@keyframes loop {

from { transform: rotate(0deg); }

to { transform: rotate(360deg); }

}

```

二、建网使用CSS伪元素实现动态加载效果

通过`::before`或`::after`伪元素创建旋转的自建站自站加载转加载动画,无需额外元素。建网

```css

body {

position: relative;

overflow: hidden;

}

body::before {

content: '';

position: absolute;

top: 50%;

left: 50%;

transform: translate(-50%,自建站自站加载转 -50%);

width: 50px;

height: 50px;

border-radius: 50%;

background-color: fff;

box-shadow: 0 2px 0 666;

animation: spin 1.5s linear infinite;

}

@keyframes spin {

from { transform: rotate(0deg); }

to { transform: rotate(360deg); }

}

```

三、结合JavaScript实现动态加载提示

适用于AJAX请求或页面加载时显示加载动画,建网请求完成后自动隐藏。自建站自站加载转

HTML结构

添加一个加载提示元素,建网初始状态隐藏。自建站自站加载转

```html

加载中...

```

CSS样式

与纯CSS方法相同,建网定义旋转动画。自建站自站加载转

JavaScript控制

在发起AJAX请求前显示加载提示,请求完成后隐藏。

```javascript

document.getElementById('btnQuery').onclick = function() {

document.getElementById("loading").style.display = 'block';

// 发起AJAX请求

// 示例:fetch('data.json')

// .then(response => response.json())

// .then(data => {

// // 处理数据

// document.getElementById("loading").style.display = 'none';

// })

// .catch(error => {

// console.error('Error:', error);

document.getElementById("loading").style.display = 'none';

// });

};

```

四、响应式加载提示

根据浏览器窗口大小动态调整加载提示位置,避免遮挡内容。

```javascript

window.onload = function() {

var loadingTop = window.innerHeight - 61 > 0 ? (window.innerHeight - 61) / 2 : 0;

var loadingLeft = window.innerWidth - 215 > 0 ? (window.innerWidth - 215) / 2 : 0;

var loadingHtml = '页面加载中...';

document.open();

document.write(loadingHtml);

document.close();

window.onresize = function() {

// 可选:调整加载提示位置

};

};

```

总结

以上方法可根据需求选择实现方式:

纯CSS:

适用于简单静态加载提示

动态加载:结合JavaScript实现AJAX请求时的加载效果

响应式设计:通过JavaScript调整加载提示位置

建议优先使用纯CSS方法,兼顾兼容性和性能,动态加载场景再结合JavaScript增强体验。

联系我们

如果您想对赣农惠的、、、、等产品进行相关了解可以拨打电话进行咨询,联系热线:020-123456789