我正在嘗試在我的一個項目中使用 react-select。在將wordWrap必須是“滾動”。但是,如果選項長度超過菜單的寬度,并且如果我向右滾動,則懸停顏色不會填充到整個寬度。以下是代碼供參考。取自https://codesandbox.io/s/modest-curie-etoj3并進行了一些修改。import React from "react";import ReactDOM from "react-dom";import Select from "react-select";import "./styles.css";function App() { const customStyles = { control: (base, state) => ({ ...base, width: 300, background: "#023950", // match with the menu borderRadius: state.isFocused ? "3px 3px 0 0" : 3, // Overwrittes the different states of border borderColor: state.isFocused ? "yellow" : "green", // Removes weird border around container boxShadow: state.isFocused ? null : null, "&:hover": { // Overwrittes the different states of border borderColor: state.isFocused ? "red" : "blue" } }), menu: base => ({ ...base, width: 300, // override border radius to match the box borderRadius: 0, // beautify the word cut by adding a dash see https://caniuse.com/#search=hyphens for the compatibility hyphens: "auto", // kill the gap marginTop: 0, textAlign: "left", // prevent menu to scroll y wordWrap: "normal" }), menuList: base => ({ ...base, // kill the white space on first and last option padding: 0 }) }; const options = [ { label: "option 1 akjbalskej", value: 1 }, { label: "option 2 akjbalskej", value: 2 }, { label: "option 3 akjbalskej", value: 3 }, { label: "option 4 akjbalskej", value: 4 }, { label: "option 5 akjbalskej", value: 5 },我對反應和前端開發相當陌生。有人可以幫我嗎?提前致謝。
反應選擇:背景顏色不會填滿 wordWrap 上的全寬:“滾動”
慕娘9325324
2021-06-29 13:02:50