I wanted to find a solution to this peculiarity. I am trying to set a gradient background in the body of my application, but it seems that my body does not reach 100% of the screen and this causes a duplication of the background. I had never seen anything like this before, would anyone know why?
app.js:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
serviceWorker.unregister();
App.js:
import React, { useState, useEffect } from 'react';
import { ClipLoader } from 'halogenium';
import {useSpring, animated} from 'react-spring'
import ComponentCentral from './components/componentCentral/ComponentCentral'
import './App.css';
import NavBar from './components/navbar/NavBar'
import Footer from './components/footer/Footer'
function App() {
const estilo = useSpring({opacity: 1, from: {opacity: 0}})
const [conteudoPage, setConteudoPage] = useState(<animated.div style={estilo}><ClipLoader className="loaderCircle" color="#26A65B" size="200px"/></animated.div>);
const [usuario, setUsuario] = useState("");
return (
<div className="App">
<NavBar usuario={usuario}></NavBar>
{conteudoPage}
<Footer></Footer>
</div>
);
}
export default App;
Index css:
html, body {
padding: 0;
margin : 0;
width : 100%;
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing : antialiased;
-moz-osx-font-smoothing: grayscale;
background : linear-gradient(-45deg, #85FFBD 0%, #FFFB7D 100%);
/* background-size: 200%; */
}
#root{
height: 100%;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
hr {
border : 0;
height : 1px;
background : #333;
background-image: linear-gradient(to right, #ccc, #333, #ccc);
margin-top : 25px
}
a.envelopeOK:link,
a.envelopeOK:visited {
background-color: #84F0B9;
color : #135D36;
padding : 14px 25px;
text-align : center;
text-decoration : none;
display : inline-block;
border-radius : 5px;
}
a.envelopeOK:hover,
a.envelopeOK:active {
background-color: #41f397;
}
I'll send images of what happened
image showing duplicate gradient
Would you know how to leave the body 100% for the gradient not to repeat?
EDIT:
Thanks to everyone who helped me, I unified some solutions and managed to solve my problem. As I'm working with react, I end up placing many nested divs where I only set body sizes and didn't let my other divs grow by themselves. My solution: put only default padding and margin 0 settings in the body and all the expansion part of the heigth and background I put in the body's daughter div: #root. With that, the body increases with the root div and it increases while the content is generated.
body {
padding: 0;
margin: 0;
}
#root {
min-height: 100vh;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background: linear-gradient (-45deg, # 85FFBD 0%, # FFFB7D 100%);
}
I checked your code Everything looks ok! What is this code for??
hr {
border : 0;
height : 1px;
background : #333;
background-image: linear-gradient(to right, #ccc, #333, #ccc);
margin-top : 25px
}
try removing this and see what happens.
Add a container in the body:
.container {
height:100vh
}
由于我最终通过合并和测试工作人员的部分 css 来解决问题,因此我会将其留在编辑中,因为它已解决,谢谢大家!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.