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) 样式编写的更多相关文章

  1. 2. react 简书 头部(header) 图标添加

    1. 访问 iconfont 并注册 登陆 2. 进入 iconfont 头部 图标管理->我的项目 3. 点击右边的文件夹 + 号 图标 创建我的项目 输入项目名称即可 4.在 搜索框 搜索 ...

  2. react 简书开发笔记

    详见文章<React简书开发实战课程笔记>

  3. 3 react 简书 添加 头部搜索动态效果

    1. 添加动态效果组件 yarn add react-transition-group 2. 修改 src/common/header/index.js import React, {Componen ...

  4. React 简书

    create-react-app   jianshu yarn add styled-components -D       利用js写css样式  样式会更高效 https://github.com ...

  5. 1. react 简书 项目初始化

    1. 创建 react 项目 npx create-react-app my-app 2. src 目录下删除 除了 index.js index.css app.js 的文件 3. 引入 style ...

  6. react简书

    开发项目之前的准备 https://www.chromefor.com/  登录此网站 下载相关crx react插件 不然要FQ 下载 React Developer Tools 谷歌插件下载 Re ...

  7. 4 react 简书 引入 redux 的 combineReducers 对 redux 数据进行管理

    1. src 下的 common 下的 header 创建 store 文件夹 下创建 reducer.js # src/common/header/store/reducer.js const st ...

  8. react简书笔记一 环境, git 和 项目 关联

    1.. 建立git项目  ( 码云, github 都可以 ), 具体步骤: https://www.cnblogs.com/andy-lehhaxm/p/10720717.html 1.1  git ...

  9. 把cnblogs变成简书 - cnblogs博客自定义皮肤css样式

    吐槽 博客园cnblogs作为老牌的IT技术博客类网站,为广大的开发者提供了非常不错的学习交流平台. 虽然博客内容才是重点,但是如果有赏心悦目的页面不更好吗! cnblogs可以更换博客模板,并且提供 ...

随机推荐

  1. string简单成员函数的实现

    原文:https://blog.csdn.net/zcyzsy/article/details/52146124 #include<iostream> using namespace st ...

  2. 077、Java数组之分步实现数组操作

    01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...

  3. NFS实战

    博客实践: (1) nfs server导出/data/application/web,在目录中提供wordpress; (2) nfs client挂载nfs server导出的文件系统至/var/ ...

  4. SciPy 常量

    章节 SciPy 介绍 SciPy 安装 SciPy 基础功能 SciPy 特殊函数 SciPy k均值聚类 SciPy 常量 SciPy fftpack(傅里叶变换) SciPy 积分 SciPy ...

  5. python三大神器===》迭代器

    迭代器: 1.认识迭代器 迭代器是访问集合元素的一种方式.迭代器是一个可以记住遍历的位置的对象.迭代器对象从集合的第一个元素开始访问,直到所有的元素被访问完结束.迭代器只能往前不会后退. 我们怎样才能 ...

  6. oracle根据一张表更新另外一张表

    知道是两张表进行更新,之前作过mysql的,直接就写了: update a,b set a.code = b.code wehre a.id = b.id 然后就报错了,上网查了下知道oracle不能 ...

  7. shiro#springboot

    1. shiro的使用围绕着securityManager,权限需要从realm中来. securityManager可以设置realm或者realms,或者通过设置authenticator来设置r ...

  8. MySQL如何获取时间戳

    时间戳函数:current_timestamp() 将时间列格式设为timestamp,设定其默认值为CURRENT_TIMESTAMP. 插入一条新纪录,数据库就会自动在时间列存储当前时间.

  9. supervisor的介绍

    1.supervisor 简介 Supervisor 是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,不支持Windows系统.它可以很方便的 ...

  10. LeetCode141 环形链表(Java—HashSet简单应用or双指针)

    题目: 判断给出的链表中是否存在环. 思路: 1. 遍历整个链表,将走过的节点的内存地址保存下来,如果再次走到同样的内存地址,说明链表中有环.时间复杂度为O(n). 2. 设置两个指针,fast指针每 ...