2. react 简书 头部 (header) 样式编写
1. 在 src 下 创建 common 文件下 创建 header 文件夹下 创建 index.js
#src/common/header/index.js
import React, {Component} from 'react';
import {
HeaderWrapper,
Logo,
Nav,
NavItem,
NavSearch,
Addtion,
Button
} from './style';
class Header extends Component{
render(){
return (
<HeaderWrapper>
<Logo />
<Nav>
<NavItem className="left active">首页</NavItem>
<NavItem className="left">下载</NavItem>
<NavItem className="right">登陆</NavItem>
<NavItem className="right">注册</NavItem>
<NavSearch ></NavSearch>
</Nav>
<Addtion>
<Button className='writting'>写文章</Button>
<Button className='reg'>注册</Button>
</Addtion>
</HeaderWrapper>
);
}
}
export default Header;
2. app.js 引入 header 组件并显示
# app.js
import React from 'react';
import Header from './common/header'
function App() {
return (
<div>
<Header />
</div>
);
}
export default App;
3. 在 src 下 创建 common 文件下 创建 header 文件夹下 创建 style.js 编写头部样式
# src/header/style.js
import styled from 'styled-components';
// 引入 logo 图片
import LogoPic from '../../statics/logo.png';
export const HeaderWrapper = styled.div`
postition: relate;
height:56px;
border-bottom:1px solid #f0f0f0;
`;
export const Logo = styled.a.attrs({
href : '/'
})`
position: absolute;
left : 0;
top : 0;
display: block;
height:56px;
width:100px;
background: url(${LogoPic}) no-repeat;
background-size: contain;
`;
export const Nav = styled.div`
width:960px;
box-size: box-size;
padding-right: 70px;
height: 56px;
margin-left: 100px;
`
export const NavItem = styled.div`
&.left {
float: left;
}
&.right {
float: right;
color: #969696;
}
&.active {
color: #ea6f5a;
}
line-height: 56px;
front-size: 15px;
padding-left: 6px;
padding-right: 12px;
color: #333;
`;
export const NavSearch = styled.input.attrs({
placeholder : '搜索'
})`
width : 160px;
height : 38px;
border: none;
outline : none;
padding : 0 20px;
box-size: box-size;
margin-top: 9px;
margin-left: 20px;
border-radius : 19px;
background: #eee;
font-size: 14px;
&::placeholder:
`;
export const Addtion = styled.div`
position:absolute;
right: 0;
top: 0;
height: 65px;
`;
export const Button = styled.div`
float:right;
line-height:38px;
margin-top:9px;
margin-right: 20px;
border-radius: 19px;
border : 1px solid rgba(236,97,73,.7);
color : #fff;
padding : 0 20px;
&.reg{
color:#ea6f5a;
}
&.writting{
background:#ea6f5a;
}
`;
2. react 简书 头部 (header) 样式编写的更多相关文章
- 2. react 简书 头部(header) 图标添加
1. 访问 iconfont 并注册 登陆 2. 进入 iconfont 头部 图标管理->我的项目 3. 点击右边的文件夹 + 号 图标 创建我的项目 输入项目名称即可 4.在 搜索框 搜索 ...
- react 简书开发笔记
详见文章<React简书开发实战课程笔记>
- 3 react 简书 添加 头部搜索动态效果
1. 添加动态效果组件 yarn add react-transition-group 2. 修改 src/common/header/index.js import React, {Componen ...
- React 简书
create-react-app jianshu yarn add styled-components -D 利用js写css样式 样式会更高效 https://github.com ...
- 1. react 简书 项目初始化
1. 创建 react 项目 npx create-react-app my-app 2. src 目录下删除 除了 index.js index.css app.js 的文件 3. 引入 style ...
- react简书
开发项目之前的准备 https://www.chromefor.com/ 登录此网站 下载相关crx react插件 不然要FQ 下载 React Developer Tools 谷歌插件下载 Re ...
- 4 react 简书 引入 redux 的 combineReducers 对 redux 数据进行管理
1. src 下的 common 下的 header 创建 store 文件夹 下创建 reducer.js # src/common/header/store/reducer.js const st ...
- react简书笔记一 环境, git 和 项目 关联
1.. 建立git项目 ( 码云, github 都可以 ), 具体步骤: https://www.cnblogs.com/andy-lehhaxm/p/10720717.html 1.1 git ...
- 把cnblogs变成简书 - cnblogs博客自定义皮肤css样式
吐槽 博客园cnblogs作为老牌的IT技术博客类网站,为广大的开发者提供了非常不错的学习交流平台. 虽然博客内容才是重点,但是如果有赏心悦目的页面不更好吗! cnblogs可以更换博客模板,并且提供 ...
随机推荐
- ng之邮箱校验
$scope.sendMail = function () { // console.log($scope.inputValue.inputEmail); //校验邮箱格式是否正确 if (!$sco ...
- Day4 - C - 六度分离 HDU - 1869
1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一个名为“小世界现象(small world phenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人,即只用6个人 ...
- PyQt5点击菜单栏弹出新窗口,解决新窗口闪退的实现方法
实现的功能为:当点击菜单中某个菜单时,会弹出一个新窗口,下面就列出部分代码 def mail_setting(self): log.debug("open mail settings&quo ...
- Pycharm 报错 Environment location directory is not empty 解决
新电脑clone项目后发现Project Interpreter无法配置, New environment 选择后无法应用, 鼠标悬停在Location 提示 Environment location ...
- C# 篇基础知识7——字符串
文字是信息的主要表达方式,因此文字处理是计算机的一项重要功能之一.现在来深入研究C#中字符串的各种特性.正则表达式的基本概念以及如何用正则表达式进行文本匹配. 1.char结构 C#中的字符用Syst ...
- 我的Grunt之旅-序章
时间:2018-03-05 13:52 事件:安装Grunt 相关网址: grunt官网:https://gruntjs.com node.js下载地址 :https://nodejs.org/en ...
- Java开发程序员必须要学会的linux命令总结
查找文件 find / -name filename.txt 根据名称查找/目录下的filename.txt文件. find . -name "*.xml" 递归查找所有的xml文 ...
- MS SQLSERVER 自增ID列竟然会重复
MS SQLSERVER 2008 R2 datacenter edition 自增的ID列,设为了主键. 从没遇到过的情况.
- mpvue + Vant weapp + 微信云服务 打造小程序应用
写在前面的话: 从事小程序开发已经大半年的时间了,但是一直都是再用原生写项目.一直想着用框架自己写一个小程序,但苦于一直没有时间.正好最近项目搁置,有了空闲时间,就研究了下mpvue + Vant w ...
- 软件包管理:RPM包管理-yum在线管理
CentOS 是免费的的 RedHat需要付费 1.IP地址配置 setup #使用setup工具 (这种方式配置的永久有效 同时还可以配置掩码 网关等) 直接输入setup就会弹出(注意的是该命令 ...