你好,我对Js的react 是新的,我对css和挣扎的react 不是很好.

我正在try 实现一个基本的Cookie横幅设计. 以下是我到目前为止所try 的全部代码

JS:

import React from "react";
import { withWidth } from "@material-ui/core";
import style from './Cookie.module.css';

function Cookies(props) {
    return (
        <React.Fragment>

            <div ref={props.forwardedRef}>





                <div className={style.cookies}>
                    <div className={style.content}>
                        <p className={style.header}>We use cookies on this site to enhance your user experience</p>

                        <p className={style.message}> By clicking any link on this page you are giving your consent for us to set cookies. Detailed information, also on the right to withdraw consent, can be found in the <a href="/" target="_blank" rel="noreferrer">website's privacy policy.</a></p>

                        <div className={style.click}>
                            <button className={style.button}>
                                Yes I agree
                            </button>
                        </div>

                    </div>

                </div>

            </div>
        </React.Fragment >
    )
}
export default withWidth()(Cookies);

Css:以下内容:

.cookies {
  overflow: hidden;
  background-color: #333;
  position: fixed;
  bottom: 0;
  width: 100%;
}

.content {

  padding-left: 100px;
  padding-top: 5px;
}

.header {
  color: #FFFFFF;
  font-size: 20px;
}

.message {
  color: #FFFFFF;
  font-size: 16px;
}

.click {
  left: 0;
}

.button {
  background-color: #3f7edf;
  color: #FFFFFF;
  font-size: 13px;
  height: 50px;
  width: 100px;
  border-radius: 5px;
  border-color: #3f7edf;
}

我try 添加自定义的CSS,并为Cookie横幅实现了一个基本的用户界面.

这是我目前的Cookie Banner: CURRENT DESIGN

以下是我正在努力实现的设计: MY GAOL

推荐答案

您可以将headermessage div包装在另一个div中,如下所示

<div className={style.cookies}>
  <div className={style.content}>
    <div className={style.main}>
      <p className={style.header}>We use cookies on this site to enhance your user experience</p>
      <p className={style.message}> By clicking any link on this page you are giving your consent for us to set cookies. Detailed information, also on the right to withdraw consent, can be found in the <a href="/" target="_blank" rel="noreferrer">website's privacy policy.</a></p>
    </div>
    <div className={style.click}>
      <button className={style.button}>Yes I agree</button>
    </div>
  </div>
</div>

把这个加到css file上:

.content {
  padding-left: 100px;
  padding-top: 5px;
  display: flex;
  justify-content:center;
  align-items:flex-end
}
.main{
  width: 55%
}

.click {
  width:45%;
  margin-right: 5px
  left: 0;
}

Css相关问答推荐

如何在CSS calc()中使用反向百分比/无单位计算?

如何将bslib::card()中的扩展按钮移到右上方,其中full_screen = TRUE?

如何将div与图像维度进行zoom ?

我应该在哪里放置expo /Reaction本地项目的CSS重置文件?

如果`line-Height:1`,则垂直字母所占的高度

寻找组件中最大的元素来设置其他组件的高度

如何在不使用 !important 的情况下提高优先级?

用户代理必须处理(或表现得好像他们这样做)每个链接就好像链接指向单独的样式表这句话是什么意思?

react 样式的条件类名称设置

CSS中元素的重叠

基于类的 CSS Select 器

CSS和 Select 器 - 我可以 Select 具有多个类的元素吗?

边界半径不起作用

如何在 CSS 中控制列表样式类型光盘的大小?

如何在 CSS 中绘制一个圆形扇区?

在 Twitter Bootstrap 中创建圆角的正确方法

更改 FontAwesome 图标的字体粗细?

如何根据容器大小设置字体大小?

如何将页脚(div)与页面底部对齐?

为什么对 HTML 表单而不是表格使用定义列表(DL、DD、DT)标签?