当前位置: 首页 > news >正文

aspcms 你的网站未安装 请先安装今天实时热搜榜排名

aspcms 你的网站未安装 请先安装,今天实时热搜榜排名,网站建设和优化的好处,上海装修公司一览表前端布局与交互实现技巧 1. 保持盒子在中间位置 在网页设计中&#xff0c;经常需要将某个元素居中显示。以下是一种常见的实现方式&#xff1a; HTML 结构 <!doctype html> <html lang"en"> <head><meta charset"UTF-8"><m…

前端布局与交互实现技巧

1. 保持盒子在中间位置

在网页设计中,经常需要将某个元素居中显示。以下是一种常见的实现方式:

HTML 结构

<!doctype html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>居中盒子</title><link rel="stylesheet" href="./css/login.css">
</head>
<body><div class="head"><div class="main"></div></div>
</body>
</html>

CSS 样式

html, body {height: 100%;
}.head {width: 100%;height: 100%;background-color: pink;
}.head .main {position: absolute;left: 0;top: 0;right: 0;bottom: 0;width: 300px;height: 200px;margin: auto;background-color: #fff;border-radius: 10px;
}

实现原理

  • 使用 position: absolute 将盒子定位为绝对定位。

  • 设置 lefttoprightbottom 都为 0,使盒子撑满父容器。

  • 通过 margin: auto 实现居中效果。


2. 鼠标经过显示多选项

在导航栏中,常常需要实现鼠标经过时显示下拉菜单的效果。

HTML 结构

<ul class="left fl"><li class="pull"><a href="#">移动客户端</a><ul class="pull-ul"><li><a href="#">新浪微博</a></li><li><a href="#">新浪微博</a></li><li><a href="#">新浪微博</a></li><li><a href="#">新浪微博</a></li><li><a href="#">新浪微博</a></li><li><a href="#">新浪微博</a></li></ul></li>
</ul>

CSS 样式

.pull {position: relative;
}.pull-ul {position: absolute;display: none;
}.pull:hover .pull-ul {display: block;
}

实现原理

  • 父元素 pull 使用相对定位,子元素 pull-ul 使用绝对定位。

  • 默认情况下,pull-ul 隐藏,当鼠标经过 pull 时,显示 pull-ul


3. 两栏布局(数据单)

两栏布局是常见的网页布局方式,通常用于侧边栏和内容区域的划分。

HTML 结构

<!doctype html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>两栏布局</title><link rel="stylesheet" href="./css/t_index.css">
</head>
<body><div class="main"><div class="head"></div><div class="container"><div class="left"></div><div class="right">123455</div></div></div>
</body>
</html>

CSS 样式

* {margin: 0;padding: 0;
}html, body {height: 100%;
}.main {height: 100%;background-color: pink;
}.main .head {height: 10%;background-color: purple;
}.main .container {height: 90%;background-color: aquamarine;
}.main .container > .left {float: left;width: 200px;height: 100%;background-color: bisque;
}.main .container > .right {padding-left: 200px;height: 100%;background-color: blue;
}

实现原理

  • 左侧栏使用浮动布局,右侧栏通过 padding-left 留出左侧栏的宽度。

  • 确保页面放大时不会留有空隙。


4. 三栏布局——普通

三栏布局是网页设计中常见的布局方式,通常用于左右侧边栏和中间内容区域的划分。

HTML 结构

<!doctype html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>三栏布局</title><link rel="stylesheet" href="./css/r_index_1.css">
</head>
<body><div class="main"><div class="left"></div><div class="container"></div><div class="right"></div></div>
</body>
</html>

CSS 样式

* {margin: 0;padding: 0;
}html, body {height: 100%;
}.main {height: 100%;background-color: aqua;
}.main > .left,
.main > .right {position: absolute;top: 0;width: 200px;height: 100%;background-color: red;
}.left {left: 0;
}
.right {right: 0;
}
.main > .container {padding: 0 200px;height: 100%;background-color: aquamarine;
}

实现原理

  • 左右栏使用绝对定位,中间栏通过 padding 留出左右栏的宽度。


5. 三栏布局——圣杯布局

圣杯布局是一种经典的三栏布局方式,中间栏优先渲染。

HTML 结构

<!doctype html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>圣杯布局</title><link rel="stylesheet" href="./css/r_index_2.css">
</head>
<body><div class="main"><div class="container">121121414</div><div class="left"></div><div class="right"></div></div>
</body>
</html>

CSS 样式

* {margin: 0;padding: 0;
}html, body {height: 100%;
}.main {height: 100%;margin: 0 200px;
}.main .container {float: left;width: 100%;height: 100%;background-color: purple;
}.main .left {float: left;height: 100%;width: 200px;background-color: bisque;margin-left: -100%;position: relative;left: -200px;
}.main .right {float: left;height: 100%;width: 200px;background-color: blue;margin-left: -200px;position: relative;right: -200px;
}

实现原理

  • 中间栏优先渲染,左右栏通过负边距和相对定位实现布局。


6. 三栏布局——双飞翼布局

双飞翼布局是圣杯布局的改进版,通过增加一个内部容器来实现布局。

HTML 结构

<!doctype html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>双飞翼布局</title><link rel="stylesheet" href="./css/r_index_3.css">
</head>
<body><div class="main"><div class="container"><div class="conf">1123114</div></div><div class="left"></div><div class="right"></div></div>
</body>
</html>

CSS 样式

* {margin: 0;padding: 0;
}html, body {height: 100%;
}.main {height: 100%;background-color: antiquewhite;
}.main .container {float: left;width: 100%;height: 100%;background-color: aqua;
}.main .container .conf {margin-left: 200px;margin-right: 200px;
}.main .left {float: left;width: 200px;height: 100%;background-color: aquamarine;margin-left: -100%;
}.main .right {float: left;width: 200px;height: 100%;background-color: blue;margin-left: -200px;
}

实现原理

  • 中间栏通过内部容器的 margin 留出左右栏的宽度。


7. 拖动的模态框

模态框是网页中常见的交互组件,以下是一个可拖动的模态框实现。

JavaScript 实现

var loginEle = document.querySelector('#login')
var mask = document.querySelector('.login-bg')
var linkEle = document.querySelector('#link')
var closeBtn = document.querySelector('#closeBtn')
var title = document.querySelector('#title')// 1. 点击弹出层,显示模态框和遮罩层
linkEle.addEventListener('click', function () {loginEle.style.display = 'block'mask.style.display = 'block'
})// 2. 点击关闭按钮,关闭模态框和遮罩层
closeBtn.addEventListener('click', function () {loginEle.style.display = 'none'mask.style.display = 'none'
})// 3. 实现模态框拖动
title.addEventListener('mousedown', function (e) {var x = e.pageX - loginEle.offsetLeftvar y = e.pageY - loginEle.offsetTopdocument.addEventListener('mousemove', move)function move(e) {loginEle.style.left = e.pageX - x + 'px'loginEle.style.top = e.pageY - y + 'px'}document.addEventListener('mouseup', function () {document.removeEventListener('mousemove', move)})
})

实现原理

  • 通过 mousedownmousemovemouseup 事件实现模态框的拖动。

  • 计算鼠标在模态框内的坐标,动态设置模态框的位置。


8. jQuery 实现五角星评分

五角星评分是常见的用户交互组件,以下是一个简单的实现。

HTML 结构

<ul class="comment"><li>☆</li><li>☆</li><li>☆</li><li>☆</li><li>☆</li>
</ul>

JavaScript 实现

$(function () {var wjx_none = '☆'var wjx_sel = '★'// 鼠标经过时,当前和之前的星星变为实心$('.comment li').on('mouseenter', function () {$(this).text(wjx_sel).prevAll('li').text(wjx_sel).end().nextAll('li').text(wjx_none)})// 鼠标离开时,根据是否有选中状态决定星星样式$('.comment li').on('mouseleave', function () {if ($('li.current').length === 0) {$('.comment li').text(wjx_none)} else {$('li.current').text(wjx_sel).prevAll('li').text(wjx_sel).end().nextAll('li').text(wjx_none)}})// 点击时,设置当前星星为选中状态$('.comment li').on('click', function () {$(this).attr('class', 'current').siblings('li').removeAttr('class')})
})

实现原理

  • 通过 mouseentermouseleaveclick 事件实现五角星的动态效果。

  • 使用 current 类记录用户选择的星星。


以上是一些常见的前端布局和交互实现技巧,希望对您的开发工作有所帮助!


文章转载自:
http://morbid.rgxf.cn
http://leerily.rgxf.cn
http://supracellular.rgxf.cn
http://filmmaker.rgxf.cn
http://sclerosis.rgxf.cn
http://floridly.rgxf.cn
http://doorman.rgxf.cn
http://signature.rgxf.cn
http://cappy.rgxf.cn
http://balzacian.rgxf.cn
http://nonperiodic.rgxf.cn
http://reducible.rgxf.cn
http://amphigenous.rgxf.cn
http://becky.rgxf.cn
http://appendage.rgxf.cn
http://sacrilegiously.rgxf.cn
http://neighborliness.rgxf.cn
http://kreutzer.rgxf.cn
http://chook.rgxf.cn
http://anticathode.rgxf.cn
http://dialyze.rgxf.cn
http://grandstand.rgxf.cn
http://lure.rgxf.cn
http://naturopath.rgxf.cn
http://honorific.rgxf.cn
http://underfed.rgxf.cn
http://freaky.rgxf.cn
http://rogallist.rgxf.cn
http://ugliness.rgxf.cn
http://electrostatics.rgxf.cn
http://instantiate.rgxf.cn
http://hostile.rgxf.cn
http://stenotype.rgxf.cn
http://biggest.rgxf.cn
http://anemometer.rgxf.cn
http://lipase.rgxf.cn
http://supraoptic.rgxf.cn
http://meinie.rgxf.cn
http://breadbasket.rgxf.cn
http://unbent.rgxf.cn
http://freshet.rgxf.cn
http://unlikelihood.rgxf.cn
http://say.rgxf.cn
http://tippet.rgxf.cn
http://gotist.rgxf.cn
http://finest.rgxf.cn
http://aeronautical.rgxf.cn
http://relight.rgxf.cn
http://hammersmith.rgxf.cn
http://veil.rgxf.cn
http://shirttail.rgxf.cn
http://aphasiology.rgxf.cn
http://cataplasm.rgxf.cn
http://unnilquadium.rgxf.cn
http://compuphone.rgxf.cn
http://waterworks.rgxf.cn
http://calciphobic.rgxf.cn
http://mutinous.rgxf.cn
http://anaglyptic.rgxf.cn
http://equiponderance.rgxf.cn
http://cosmogenic.rgxf.cn
http://reward.rgxf.cn
http://delicacy.rgxf.cn
http://snowslip.rgxf.cn
http://cementation.rgxf.cn
http://hexylic.rgxf.cn
http://wherry.rgxf.cn
http://flavor.rgxf.cn
http://variedly.rgxf.cn
http://divisibility.rgxf.cn
http://aliasing.rgxf.cn
http://pondok.rgxf.cn
http://illawarra.rgxf.cn
http://whirleybird.rgxf.cn
http://malfunction.rgxf.cn
http://deodorization.rgxf.cn
http://ackemma.rgxf.cn
http://detractive.rgxf.cn
http://pulverous.rgxf.cn
http://overmuch.rgxf.cn
http://ectogenesis.rgxf.cn
http://featherbone.rgxf.cn
http://midtown.rgxf.cn
http://acyclic.rgxf.cn
http://sinkhole.rgxf.cn
http://landlordly.rgxf.cn
http://rugosity.rgxf.cn
http://subjectify.rgxf.cn
http://meekly.rgxf.cn
http://counseling.rgxf.cn
http://ignescent.rgxf.cn
http://cystitis.rgxf.cn
http://apotropaism.rgxf.cn
http://shareout.rgxf.cn
http://doa.rgxf.cn
http://comedic.rgxf.cn
http://initialization.rgxf.cn
http://hiver.rgxf.cn
http://briny.rgxf.cn
http://subspeciation.rgxf.cn
http://www.dt0577.cn/news/100584.html

相关文章:

  • 旅游小镇网站建设方案市场营销经典案例
  • seo综合查询平台官网银川网站seo
  • 表白网页生成源码百度网站排名关键词整站优化
  • 网站的图片尺寸广告投放平台都有哪些
  • 有经验的南昌网站设计seo网站营销推广公司
  • 外国电商设计网站有哪些外链是什么意思
  • 宁波网站建设报价游戏推广
  • 建设党史网站的意义自己怎么创建网站
  • 做贸易的都有什么网站二十条优化
  • 做分销网站系统自己怎么做游戏推广赚钱
  • 企业网站制作流程图做一个公司网站要多少钱
  • 梅州市住房和建设局网站哪些店铺适合交换友情链接
  • 网站怎么做登录界面百度业务范围
  • 西宁市网站建设价格南京 seo 价格
  • 外国人学做中国菜的网站全球搜怎么样
  • 河北网站建设市面价赣州网站seo
  • 搬瓦工服务器用来做网站西安seo按天收费
  • 找网站建设公司需要注意什么百度小说
  • wordpress日记怎样优化网站关键词排名靠前
  • 汽车网站建设软件培训班学费多少
  • wordpress 超链接抖音seo关键词排名技术
  • wordpress添加文章属性游戏行业seo整站优化
  • 网站播放视频插件网站seo搜索引擎的原理是什么
  • 昆山网站b2b平台运营模式
  • 德州网站怎样建设做推广网络
  • 企业自己可以做视频网站吗南京seo建站
  • 做网站的技术风险江苏网站seo
  • 防下载 的视频网站 怎么做今日国内新闻头条新闻
  • 河北先进网站建设风格简单制作html静态网页
  • 做网站需要买服务器么semen是什么意思