英文:
How to adjust the sidebar size in React
问题
看起来你在React中遇到了一些问题。以下是你提供的代码的中文翻译:
// App.css
.sidemenu {
width: 1000px;
border: 1px solid white;
}
// App.js
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<aside className="sidemenu">
<h1>侧边栏</h1>
</aside>
<section>
</section>
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
编辑 <code>src/App.js</code> 并保存以重新加载。
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
学习React
</a>
</header>
</div>
);
}
export default App;
希望这能帮助你解决问题。
英文:
I am new to react, and I am working on my first project, following https://www.youtube.com/watch?v=qwM23_kF4v4.
At the very beginning, I followed all the steps and tries to set a sidebar on the left with "240px", the expected is as left, but what I made is as right.
The code is below. I only add the sidemenu
part.
I have rechecked the code in the video many times, but it still shows as below. Furthermore, I expected the sidebar to be 50% of the screen, as shown in the video.
I have changed the sidemenu
width as "100%", "40vmin", but nothing works.
What I have tried is as follows in App.css:
.sidemenu {
width: 1000px;
border:1px solid white;
}
My App.js code is as follows:
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<aside className="sidemenua">
<h1>Aside</h1>
</aside>
<section>
</section>
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;
答案1
得分: 1
请检查你的className
是否与 CSS 选择器名称不同,应该是sidemenu
。
<aside className="sidemenu">
<h1>Aside</h1>
</aside>
英文:
please check your className
is differ from css selector name it should be
sidemenu
.
<aside className="sidemenu">
<h1>Aside</h1>
</aside>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论