2020-04-22 09:31发布
搜索框代码正常情况下是需要使用Dreamweaver来实现的。需要熟知代码来操作。对于不是做前端的学生来说。建议使用moban.cn里的模板店铺装修工具来实现搜索框的添加。可以打开moban.cn。点击PC装修。在找到店铺装修工具点击进入装修即可。可以将店招或banner图上传后。直接点击添加搜索框即可。装修完毕导出代码在店铺装修使用自定义代码模式粘进去即可。
我们的搜索框,为了不让输入的字符串把放大镜遮住,我们给input 设置padding-right 为30px,如下。
export const NavSearch = styled.input`
width: 160px;
height: 38px;
margin-top: 9px;
margin-left: 20px;
padding: 0 30px 0 20px;
box-sizing: border-box;
border: none;
outline: none;
border-radius: 19px;
background: #eee;
font-size: 14px;
color: #777;
&::placeholder {
color: #999;
}
`;
接下来,我们制作鼠标的移入移出动画效果
我们可以通过数据,控制页面的变化。在Header 组件中,我们在组件的state 中定义一个变量 focused ,如下。
constructor(props) {
super(props);
this.state = {
focused: false
然后,我们控制一下 NavSearch 与放大镜 的 className,如下。 return ( 首页 下载 登录 placeholder="搜索" className={this.state.focused ? "focused" : ""} > className={this.state.focused ? "focused iconfont" : "iconfont"} > 写文章 注册 ) 然后,我们去增加一些样式,如下。 export const SearchWrapper = styled.div` position: relative; float: left; background:red; .iconfont { position: absolute; right: 5px; bottom: 5px; width: 30px; line-height: 30px; border-radius: 15px; text-align: center; &.focused { background: #777; color: #fff; } }`; export const NavSearch = styled.input` width: 160px; height: 38px; margin-top: 9px; margin-left: 20px; padding: 0 30px 0 20px; box-sizing: border-box; border: none; outline: none; border-radius: 19px; background: #eee; font-size: 14px; color: #777; &::placeholder { color: #999; } &.focused { width: 200px; }`;然后,我们增加一些逻辑处理,给输入框 的 focus 和 blur 事件定义逻辑,如下。 placeholder="搜索" className={this.state.focused ? "focused" : ""} onFocus={this.handleFocus} onBlur={this.handleBlur} > handleFocus() {this.setState({focused: true})}handleBlur() {this.setState({focused: false})}下面,我们使用一下动画,使得样式变化可以平滑一些。动画,我们使用react 的第三方模块 react-transition-group 。github 上我们可以找到它的文档: https://reactcommunity.org/react-transition-group/然后我们使用这个模块的CSSTransition 模块就行。下面,我们就使用吧。先下载安装它 yarn add react-transition-group然后我们在Header 组件中引入import { CSSTransition } from 'react-transition-group';然后,我们用 CSSTransition标签 将 NavSearch标签包裹起来。并在 CSSTransition 中设置一些属性 timeout(动画在多少毫秒内完成),in(控制入场和出场),classNames。如下。 in={this.state.focused} timeout={200} classNames="slide" > placeholder="搜索" className={this.state.focused ? "focused" : ""} onFocus={this.handleFocus} onBlur={this.handleBlur} > className={this.state.focused ? "focused iconfont" : "iconfont"} > 好啦,这样的话。接下来,CSSTransition 会做下面的事情。当 in 中内容变为 true 时,它会在CSSTransition 包裹的组件上 挂载 slide-enter , slide-enter-active 样式,在in 中内容变为 false时,它会在CSSTransition 组件上 挂载 slide-exit , slide-exit-active 样式。好啦,下面我们来写一下样式文件。export const SearchWrapper = styled.div` position: relative; float: left; .slide-enter { transition: all .2s ease-out; } .slide-enter-active { width: 240px; } .slide-exit { transition: all .2s ease-out; } .slide-exit-active { width: 160px; } .iconfont { position: absolute; right: 5px; bottom: 5px; width: 30px; line-height: 30px; border-radius: 15px; text-align: center; &.focused { background: #777; color: #fff; } }`;好啦,这样就实现了搜索框的动画效果。下面,贴一下整体代码。Header组件代码import React, { Component } from 'react';import { HeaderWrapper, Logo, Nav, NavItem, NavSearch, Addition, Button, SearchWrapper} from './style';import '../../statics/iconfont/iconfont.css';import { CSSTransition } from 'react-transition-group'; class Header extends Component { constructor(props) { super(props); this.state = { focused: false } this.handleFocus = this.handleFocus.bind(this); this.handleBlur = this.handleBlur.bind(this); } render () { return ( 首页 下载 登录 in={this.state.focused} timeout={200} classNames="slide" > placeholder="搜索" className={this.state.focused ? "focused" : ""} onFocus={this.handleFocus} onBlur={this.handleBlur} > className={this.state.focused ? "focused iconfont" : "iconfont"} > 写文章 注册 ) } handleFocus() { this.setState({ focused: true }) } handleBlur() { this.setState({ focused: false }) } } export default Header;Header组件的样式代码import styled from 'styled-components';import logoPic from '../../statics/logo.png'; export const HeaderWrapper = styled.div` position: relative; height: 56px; border-bottom: 1px solid #f0f0f0;`; export const Logo = styled.a` position: absolute; top: 0; left: 0; display: block; width: 100px; height: 56px; background: url(${logoPic}); background-size: contain;`; export const Nav = styled.div` width: 960px; height: 100%; padding-right: 70px; box-sizing: border-box; margin: 0 auto;`; export const NavItem = styled.div` line-height: 56px; padding: 0 15px; font-size: 17px; color: #333; &.left { float: left; } &.right { float: right; color: #969696; } &.active { color: #ea6f5a; }`; export const SearchWrapper = styled.div` position: relative; float: left; .slide-enter { transition: all .2s ease-out; } .slide-enter-active { width: 240px; } .slide-exit { transition: all .2s ease-out; } .slide-exit-active { width: 160px; } .iconfont { position: absolute; right: 5px; bottom: 5px; width: 30px; line-height: 30px; border-radius: 15px; text-align: center; &.focused { background: #777; color: #fff; } }`; export const NavSearch = styled.input` width: 160px; height: 38px; margin-top: 9px; margin-left: 20px; padding: 0 30px 0 20px; box-sizing: border-box; border: none; outline: none; border-radius: 19px; background: #eee; font-size: 14px; color: #777; &::placeholder { color: #999; } &.focused { width: 200px; }`; export const Addition = styled.div` position: absolute; top: 0; right: 0; height: 56px;`; export const Button = styled.div` float: right; margin-top: 9px; margin-right: 20px; padding: 0 20px; line-height: 38px; border-radius: 19px; border: 1px solid #ec6149; font-size: 14px; &.reg { color: #ec6149; } &.writting { color: #fff; background: #ec6149; }`;Done.————————————————版权声明:本文为CSDN博主「purple_lumpy」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.csdn.net/purple_lumpy/article/details/88779396 来源于网络,仅供网友们参考
因为大批量销售东西肯定是很便宜的,成本相对较低,这是未来的一个趋势吧。
这跟两个产品的定位不同有关系。抖音内容偏向都市风格、偏向年轻人快手的风格总体偏向小城风格和乡村,有大批中老年受众
1、娱乐主播需要放得开,有才艺2、带货主播需要有货源、有粉丝,有带货技巧相比较还是带货主播比较赚钱
HTTP:超文本传输协议,是互联网上应用最为广泛的一种网络协议,是客户端和服务器端请求和应答的标准。简单的理解就是:我们通过浏览器访问网站时,浏览器和服务器(网站)端会遵守一种超文本数据传送协议,这个协议就是http协议。遵守这个协议可以让客户端(浏...
淘宝 天猫 京东 拼多多都是
外包:员不员工的不说,能干活就行,甲方公司:我们是自己人(不996我们不是兄弟,但是有福利。。)外包公司一般都是乙方接甲方的项目来做,伟甲方服务,比较辛苦但是能进步很多,得到各方面的锻炼。甲方相对轻松一些。...
总有一部分人能适应这个行业的节奏,
可以自学的,现在网络上的资源也比较多,像b站就有很多免费课程。
1、反向传播链断裂即其中有部分的变量可能被转换为 numpy 数组,虽然仍然能够参与计算,但却失去了梯度传播的能力,导致无法向后面的变量传播梯度2、学习率设置不合理如果学习率设置得太大,则容易造成 loss 变成 nan,导致模型不收敛,设置得太小,则会导致...
主要有4个重要环节主要包含内容审核、内容价值判断、内容属性包装、专题合集内容策划四个部分。
把相对应的产品信息通过各种渠道不断的宣传推广出去
我个人觉得,要做好内容运营有四大手段: 1.从内容编辑开始内容运营的的一切工作都离不开对产品内容的熟悉,而他自己的核心优势就是熟知内容、善于运用内容传播价值。而我们该怎么做?从哪里做起?我觉得内容编辑大部分为对内容进行二次加工的编辑,需把...
根据公司产品的信息,再结合当下的热点,加上以往的经验,套入相信的模板。
内容运营的核心就是通过创造或者是编辑或者是其他的方式产生出能够提升用户活跃度的内容。
流程:首先,天猫入驻流程的第一步:提交入驻资料(大约需要2小时)其次,天猫入驻流程的第二步:商家等待审核(大约需要7个工作日)再次,天猫入驻流程的第三步:完善店铺信息(大约需要1天)最后,天猫入驻流程的第四步:店铺上线费用: 天猫入驻需要缴纳...
一、天猫店铺申请条件: 1、企业注册资本不低于人民币100万元; 2、需具备一般纳税人资格; 3、自荐品牌需提供商标注册证(即R标); 4、如经营进口商品,需提供近一年内合法渠道进口证明; 5、商品必须符合法律及行业标准的质量要求; 6、所有...
最多设置5个标签!
搜索框代码正常情况下是需要使用Dreamweaver来实现的。需要熟知代码来操作。对于不是做前端的学生来说。建议使用moban.cn里的模板店铺装修工具来实现搜索框的添加。可以打开moban.cn。点击PC装修。在找到店铺装修工具点击进入装修即可。可以将店招或banner图上传后。直接点击添加搜索框即可。装修完毕导出代码在店铺装修使用自定义代码模式粘进去即可。
我们的搜索框,为了不让输入的字符串把放大镜遮住,我们给input 设置padding-right 为30px,如下。
export const NavSearch = styled.input`
width: 160px;
height: 38px;
margin-top: 9px;
margin-left: 20px;
padding: 0 30px 0 20px;
box-sizing: border-box;
border: none;
outline: none;
border-radius: 19px;
background: #eee;
font-size: 14px;
color: #777;
&::placeholder {
color: #999;
}
`;
接下来,我们制作鼠标的移入移出动画效果
我们可以通过数据,控制页面的变化。在Header 组件中,我们在组件的state 中定义一个变量 focused ,如下。
constructor(props) {
super(props);
this.state = {
focused: false
}
}
相关问题推荐
因为大批量销售东西肯定是很便宜的,成本相对较低,这是未来的一个趋势吧。
这跟两个产品的定位不同有关系。抖音内容偏向都市风格、偏向年轻人快手的风格总体偏向小城风格和乡村,有大批中老年受众
1、娱乐主播需要放得开,有才艺2、带货主播需要有货源、有粉丝,有带货技巧相比较还是带货主播比较赚钱
HTTP:超文本传输协议,是互联网上应用最为广泛的一种网络协议,是客户端和服务器端请求和应答的标准。简单的理解就是:我们通过浏览器访问网站时,浏览器和服务器(网站)端会遵守一种超文本数据传送协议,这个协议就是http协议。遵守这个协议可以让客户端(浏...
淘宝 天猫 京东 拼多多都是
外包:员不员工的不说,能干活就行,甲方公司:我们是自己人(不996我们不是兄弟,但是有福利。。)外包公司一般都是乙方接甲方的项目来做,伟甲方服务,比较辛苦但是能进步很多,得到各方面的锻炼。甲方相对轻松一些。...
总有一部分人能适应这个行业的节奏,
可以自学的,现在网络上的资源也比较多,像b站就有很多免费课程。
1、反向传播链断裂即其中有部分的变量可能被转换为 numpy 数组,虽然仍然能够参与计算,但却失去了梯度传播的能力,导致无法向后面的变量传播梯度2、学习率设置不合理如果学习率设置得太大,则容易造成 loss 变成 nan,导致模型不收敛,设置得太小,则会导致...
主要有4个重要环节主要包含内容审核、内容价值判断、内容属性包装、专题合集内容策划四个部分。
把相对应的产品信息通过各种渠道不断的宣传推广出去
我个人觉得,要做好内容运营有四大手段: 1.从内容编辑开始内容运营的的一切工作都离不开对产品内容的熟悉,而他自己的核心优势就是熟知内容、善于运用内容传播价值。而我们该怎么做?从哪里做起?我觉得内容编辑大部分为对内容进行二次加工的编辑,需把...
根据公司产品的信息,再结合当下的热点,加上以往的经验,套入相信的模板。
内容运营的核心就是通过创造或者是编辑或者是其他的方式产生出能够提升用户活跃度的内容。
流程:首先,天猫入驻流程的第一步:提交入驻资料(大约需要2小时)其次,天猫入驻流程的第二步:商家等待审核(大约需要7个工作日)再次,天猫入驻流程的第三步:完善店铺信息(大约需要1天)最后,天猫入驻流程的第四步:店铺上线费用: 天猫入驻需要缴纳...
一、天猫店铺申请条件: 1、企业注册资本不低于人民币100万元; 2、需具备一般纳税人资格; 3、自荐品牌需提供商标注册证(即R标); 4、如经营进口商品,需提供近一年内合法渠道进口证明; 5、商品必须符合法律及行业标准的质量要求; 6、所有...