react笔记之学习之使用组件完成练习

简介: react笔记之学习之使用组件完成练习

日期部分data.js

import React from 'react';
import './MyDate.css';
const MyDate = () => {
    return (
        <div className="date">
            <div className="month">
                四月
            </div>
            <div className="day">
                19
            </div>
        </div>
    );
};
export default MyDate;

日期样式data.css

/*设置日期的样式*/
.date{
    width: 90px;
    background-color: #fff;
    border-radius: 10px;
    font-weight: bold;
    text-align: center;
    overflow: hidden;
}
/*设置月份效果*/
.month{
    height: 30px;
    line-height: 30px;
    font-size: 20px;
    color: #fff;
    background-color: #D62828;
}
/*设置日期的效果*/
.day{
    height: 60px;
    line-height: 60px;
    font-size: 50px;
}

主体部分index.js

import React from 'react';
import MyDate from "./MyDate/MyDate";
import './LogItem.css'
const LogItem = () => {
    return (
        <div className="item">
            <MyDate/>
            {/* 日志内容的容器 */}
            <div className="content">
                <h2 className="desc">学习React</h2>
                <div className="time">40分钟</div>
            </div>
        </div>
    );
};
export default LogItem;

主体样式

/*设置item的样式*/
.item{
    /*开启弹性盒*/
    display: flex;
    margin: 16px 0;
    padding: 6px;
    background-color: #FCBF49;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,.2);
}
/*设置日志内容的样式*/
.content{
    flex: auto;
    text-align: center;
    font-weight: bold;
}
/*设置描述内容*/
.desc{
    font-size: 16px;
    color: #194B49;
}
/*设置学习时间*/
.time{
    color: #D62828;
}

运行结果

image.png

相关文章
|
3天前
|
前端开发 JavaScript
react学习(13)props
react学习(13)props
|
9天前
|
JavaScript 前端开发
react学习(3)创建虚拟dom的两种方式
react学习(3)创建虚拟dom的两种方式
148 66
|
9天前
|
前端开发 JavaScript 算法
react学习(1)
react学习(1)
121 66
|
8天前
|
前端开发 JavaScript
react学习(5)
react学习(5)
165 59
|
9天前
|
前端开发
react学习(2)
react学习(2)
127 57
|
8天前
|
前端开发
react学习(7)
react学习(7)
90 45
|
3天前
|
前端开发
react学习(17)回调形式的ref
react学习(17)回调形式的ref
|
3天前
|
前端开发
react学习(15)函数式组件中使用props
react学习(15)函数式组件中使用props
|
3天前
|
存储 前端开发 容器
react学习(18)createRef形式的ref
react学习(18)createRef形式的ref
|
3天前
|
前端开发
react学习(14)类式组件的构造器与props
react学习(14)类式组件的构造器与props

热门文章

最新文章