我正在创建一个网站,并且试图使页脚始终位于底部。我希望它使页脚始终位于浏览器窗口的底部,但是如果内容足够长,它将使页脚不可见并移至底部。现在,页脚始终始终位于其上方的内容之后。
我尝试设置<footer className='footer'>
<div className='icons'>
<span><a href='/'><img src={LinkedIn} alt='LinkedIn'/></a></span>
<span><a href='/'><img src={Mail} alt='Email' /></a></span>
<span><a href='/'><img src={Resume} alt='Resume' /></a></span>
</div>
<div>
<span className='footer-link'><a href='/'>Home</a></span>
<span className='footer-link'><a href='/about'>About</a></span>
<span className='footer-link'><a href='/blog'>Blog</a></span>
<span className='footer-link'><a href='/contact'>Contact</a></span>
</div>
<div className='footer-copyright'>2020 Daniel Zhang. This site was made by Daniel Zhang from scratch with React.</div>
</footer>
,但是没有用。我还试图避免设置固定高度。
相关代码
Footer.js
.footer {
align-items: center;
border-top: 1px solid grey;
border-width: 100%;
box-sizing: border-box;
display: flex;
flex-direction: column;
flex-shrink: 0;
font-size: 12px;
margin: 0px auto;
padding: 10px 0px;
text-align: center;
}
.icons img {
display: inline-block;
padding: 10px;
width: 25px;
}
.footer-link {
padding: 0px 5px;
}
.footer-link a {
color: grey;
text-decoration: none;
}
.footer-link a:hover {
color: black;
text-decoration: none;
}
.footer-copyright {
padding: 5px 0px;
}
<NavBar />
<Router>
<Switch>
<Route exact path='/' render={() => <Home />} />
<Route exact path='/about' render={() => <About />} />
<Route exact path='/blog' render={() => <Blog />} />
<Route exact path='/contact' render={() => <Contact />} />
{/* Adds page not found. */}
<Route render={() => <Home />} />
</Switch>
</Router>
<Footer />
App.js
* {
font-family: 'Lato', sans-serif;
}
html, body {
height: 100%;
margin: 0px;
}
body {
display: flex;
flex-direction: column;
}
.container {
flex: 1 0 auto;
margin: 0px auto;
width: 65%;
}
App.css
#Invoke libraries
from nltk import word_tokenize
from nltk.stem import WordNetLemmatizer
from sklearn.feature_extraction.text import TfidfVectorizer
class LemmaTokenizer(object):
def __init__(self):
self.wnl = WordNetLemmatizer()
def __call__(self, articles):
result = [self.wnl.lemmatize(t) for t in word_tokenize(articles)]
#print(result)
return result
#build example sentences with plural and singular words to check lemmatization
d = ["this is a good song by this singer",
"there are other songs that are better from other singers"]
#note that the max_df and min_df are commented as the sample size is too small
vect = TfidfVectorizer(strip_accents = 'ascii',
stop_words = 'english',
lowercase = True,
#max_df = 0.8,
#min_df = 10,
analyzer='word',
tokenizer=LemmaTokenizer())
final = vect.fit_transform(d)
print(vect.get_feature_names())
#output. Note that there is no "singers" or "songs"
[u'better', u'good', u'singer', u'song']
答案 0 :(得分:3)
尝试import datascience as ds
。
flex-direction: column;
document.getElementById('add').addEventListener('click', e => {
document.getElementById('content').innerHTML += '<br />content<br />content<br />content';
});
html,
body {
margin: 0;
height: 100%;
}
body {
display: flex;
flex-direction: column;
}
.content {
flex: 1 0 auto;
}
.footer {
background: #999;
flex-shrink: 0;
}
答案 1 :(得分:1)
您可以使用属性位置:固定;
data
答案 2 :(得分:0)
您可以使用引导程序,并在下面使用此类。
<div className="fixed-bottom">
答案 3 :(得分:0)
请尝试使用此代码。
body{
padding-bottom:50px; //same to the height of footer to avoid overlapping with fixed element
}
.footer {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height:50px; //set height as per your requirement
z-index:10;
overflow:hidden;
}