Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 镭反应伪选择器_Javascript_Reactjs_Radium - Fatal编程技术网

Javascript 镭反应伪选择器

Javascript 镭反应伪选择器,javascript,reactjs,radium,Javascript,Reactjs,Radium,两年后,我又回到了编码领域。我还没有反应过来。我真的在琢磨如何在react中使用伪选择器。我遇到了许多使用镭的答案,但只是我无法在代码中实现这一点。感谢您的帮助 以下是React组件: import React from "react"; import Radium from 'radium'; const styles = { input[type="text"] : { box-sizing: border-box; width: 100%; height:

两年后,我又回到了编码领域。我还没有反应过来。我真的在琢磨如何在react中使用伪选择器。我遇到了许多使用镭的答案,但只是我无法在代码中实现这一点。感谢您的帮助

以下是React组件:

import React from "react";
import Radium from 'radium';

const styles = {
    input[type="text"] : {
    box-sizing: border-box;
    width: 100%;
    height: calc(4em + 1px);
    margin: 0 0 1em;
    padding: 1em;
    border: 1px solid #ccc;
    background: #fff;
    resize: none;
    outline: none;
  },

  input[type="text"][required]:focus {
    border-color: #00bafa;
  },
  input[type="text"][required]:focus + label[placeholder]:before {
    color: #00bafa;
  },
  input[type="text"][required]:focus + label[placeholder]:before,
  input[type="text"][required]:valid + label[placeholder]:before {
    transition-duration: 0.2s;
    transform: translate(0, -1.5em) scale(0.9, 0.9);
  },

  input[type="text"][required]:invalid + label[placeholder][alt]:before {
    content: attr(alt);
  },

  input[type="text"][required] + label[placeholder] {
    display: block;
    pointer-events: none;
    line-height: 1em;
    margin-top: calc(-3em - 2px);
    margin-bottom: calc((3em - 1em) + 2px);
  },

  input[type="text"][required] + label[placeholder]:before {
    content: attr(placeholder);
    display: inline-block;
    margin: 0 calc(1em + 2px);
    padding: 0 2px;
    color: #898989;
    white-space: nowrap;
    transition: 0.3s ease-in-out;
    background-image: linear-gradient(to bottom, #fff, #fff);
    background-size: 100% 5px;
    background-repeat: no-repeat;
    background-position: center;
  }

};

const GmailInput = () => {
 return (
    <div>
      <form>
       <input type="text" />
       <label placeholder="Type your Email" />
      </form>
    </div>
 );
 };

 export default Radium(GmailInput);
从“React”导入React;
从“镭”进口镭;
常量样式={
输入[type=“text”]:{
框大小:边框框;
宽度:100%;
高度:计算(4em+1px);
边缘:0.01米;
填充:1em;
边框:1px实心#ccc;
背景:#fff;
调整大小:无;
大纲:无;
},
输入[type=“text”][必需]:焦点{
边框颜色:#00bafa;
},
输入[type=“text”][必需]:焦点+标签[占位符]:在{
颜色:#00bafa;
},
输入[type=“text”][必需]:焦点+标签[占位符]:在,
输入[type=“text”][必需]:有效+标签[占位符]:之前{
过渡时间:0.2s;
变换:平移(0,-1.5em)比例(0.9,0.9);
},
输入[type=“text”][必需]:无效+标签[占位符][alt]:在{
内容:attr(alt);
},
输入[type=“text”][必需]+标签[占位符]{
显示:块;
指针事件:无;
线高:1米;
边缘顶部:计算(-3em-2px);
边缘底部:计算((3em-1em)+2px);
},
输入[type=“text”][必需]+标签[占位符]:在{
内容:attr(占位符);
显示:内联块;
裕度:0计算(1米+2倍);
填充:0.2px;
颜色:#8989;
空白:nowrap;
过渡:0.3s缓进缓出;
背景图像:线性渐变(到底部,#fff,#fff);
背景尺寸:100%5px;
背景重复:无重复;
背景位置:中心;
}
};
常量gmailput=()=>{
返回(
);
};
导出默认镭(Gmail输入);
遵循语法

import React from "react";
import { StyleRoot } from "radium";

const GmailInput = props => {
  const styles = {
    boxSizing: "border-box",
    width: "100%",
    height: "calc(4em + 1px)",
    margin: "0 0 1em",
    padding: "1em",
    border: "1px solid #ccc",
    background: "#fff",
    resize: "none",
    outline: "none",
    ":hover": {
      borderColor: "#00bafa"
    }
  };

  return (
    <StyleRoot>
      <div>
        <form style={styles}>
          <input type="text" placeholder="Type your Email"></input>
        </form>
      </div>
    </StyleRoot>
  );
};

export default GmailInput;
从“React”导入React;
从“镭”导入{StyleRoot};
const gmailput=props=>{
常量样式={
框大小:“边框框”,
宽度:“100%”,
高度:“计算(4em+1px)”,
边距:“0.01米”,
填充:“1em”,
边框:“1px实心#ccc”,
背景:“fff”,
调整大小:“无”,
大纲:“无”,
“:悬停”:{
边框颜色:“00bafa”
}
};
返回(
);
};
输出默认值;
理解,

  • 您必须将所有变量放在组件的主体中

  • 当您使用基于函数的组件时,{StyleRoot}是使用Radium进行伪样式化所必需的

  • 请了解如何在React中使用JavaScript设置样式。虽然样式属性是CSS,但当您在JS中编写时,这些只是JS对象。React编译器将它们编译成CSS样式

  • 样式设置需要JSX style属性。请参见style={styles},styles是此处的变量

  • 镭(Com_名称)用于基于类的组件。它不需要基于函数的组件,但必须返回StyleRoot

  • 带有“-”的CSS语法(如框大小)将通过camelcasting(如boxsize)键入

  • (没有在此处编写所有css属性,只是为了向您展示概念。此语法已成功编译)

    遵循语法

    import React from "react";
    import { StyleRoot } from "radium";
    
    const GmailInput = props => {
      const styles = {
        boxSizing: "border-box",
        width: "100%",
        height: "calc(4em + 1px)",
        margin: "0 0 1em",
        padding: "1em",
        border: "1px solid #ccc",
        background: "#fff",
        resize: "none",
        outline: "none",
        ":hover": {
          borderColor: "#00bafa"
        }
      };
    
      return (
        <StyleRoot>
          <div>
            <form style={styles}>
              <input type="text" placeholder="Type your Email"></input>
            </form>
          </div>
        </StyleRoot>
      );
    };
    
    export default GmailInput;
    
    从“React”导入React;
    从“镭”导入{StyleRoot};
    const gmailput=props=>{
    常量样式={
    框大小:“边框框”,
    宽度:“100%”,
    高度:“计算(4em+1px)”,
    边距:“0.01米”,
    填充:“1em”,
    边框:“1px实心#ccc”,
    背景:“fff”,
    调整大小:“无”,
    大纲:“无”,
    “:悬停”:{
    边框颜色:“00bafa”
    }
    };
    返回(
    );
    };
    输出默认值;
    
    理解,

  • 您必须将所有变量放在组件的主体中

  • 当您使用基于函数的组件时,{StyleRoot}是使用Radium进行伪样式化所必需的

  • 请了解如何在React中使用JavaScript设置样式。虽然样式属性是CSS,但当您在JS中编写时,这些只是JS对象。React编译器将它们编译成CSS样式

  • 样式设置需要JSX style属性。请参见style={styles},styles是此处的变量

  • 镭(Com_名称)用于基于类的组件。它不需要基于函数的组件,但必须返回StyleRoot

  • 带有“-”的CSS语法(如框大小)将通过camelcasting(如boxsize)键入

  • (没有在此处编写所有css属性,只是为了向您展示概念。此语法已成功编译)