【发布时间】:2020-08-12 00:09:16
【问题描述】:
我是 React 的新手,我将以前纯 HTML 页面转换为 React 中的组件。如何更新 SASS 样式表以类似于以前的 HTML 格式?
这是我目前在 React 中的内容(复选框显示在右侧而不是左侧,并且复选框和标签未对齐):
这是我之前在 HTML 中拥有的,理想的格式:
checkbox.component.jsx
import React from "react";
import './checkbox.styles.scss'
const Checkbox = ({ label, isSelected, onCheckboxChange }) => (
<div className="form-check">
<li>
<label for={label}> {label} </label>
<input
type="checkbox"
name={label}
id={label}
value={label}
checked={isSelected}
onChange={onCheckboxChange}
/>
</li>
</div>
);
export default Checkbox;
checkbox.styles.scss
.form-check{
li{
list-style: none;
margin-left: 15px;
text-align:left;
}
label{
cursor: pointer;
}
label:hover{
background-color:linen;
text-decoration:underline;
}
}
【问题讨论】:
标签: javascript html css reactjs sass