Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
222 views
in Technique[技术] by (71.8m points)

html - Resize div on resizing window

I built an HTML/CSS footer for a site. But when I resize the screen, the footer doesn't resize and I can only see a clipped footer. I'd like the footer div to resize so I can see all the text at any time. Any help would be appreciated.

/* Footer Style */
#footer-background {
	position: fixed;
	height: 30px;
	left: 0%;
	bottom: 0%;
	z-index: 50;
	width: 100%;
	background: #000000;
	opacity: 0.80;
}
#footer-box{
	width: 95%;
	margin: auto;
	padding: 0 10px;
}
#footer-box h2{
	margin-top: 0;
	font-size: 20px;
	text-align: center;
	line-height: 30px;
	font-weight: normal;
	font-family: Arial, sans-serif;
	color: #A9A9A9;
}
#footer-box a{
	text-decoration: none;
	outline: none;
	color: #A9A9A9;
}
#footer-box a:hover{
	text-decoration: underline;
}
<!-- Footer bar -->
<div id="footer-background">
	<div id="footer-box">
		<h2>
		<a href="/abc/">Title 1</a> |
		<a href="/abc/">Title 2</a> |
		<a href="/abc/">Title 3</a> |
		<a href="/abc/">Title 4</a> |
		<a href="/abc/">Title 5</a> |
		<a href="/abc/">Title 6</a> |
		<a href="/abc/">Title 7</a> |
		<a href="/abc/">Title 8</a>
		</h2>			
	</div>
</div>
<!--/ Footer bar -->
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I would like to address some points here : (1) "height" property

#footer-background {
    position: fixed;
    height: 30px;
    left: 0%;
    bottom: 0%;
    z-index: 50;
    width: 100%;
    background: #000000;
    opacity: 0.80;
}

In above piece of code you added height:30px; meaning, you are restricting this element to grow if content wrap around. You can use padding: 20px; or whatever size you want so that when you scale down the screen size, content will wrap inside the element. (2) h2 has pre-defined css property

#footer-box h2{
    margin-top: 0;
    font-size: 20px;
    text-align: center;
    line-height: 30px;
    font-weight: normal;
    font-family: Arial, sans-serif;
    color: #A9A9A9;
}

h2 element has predefined margins. instead of just removing margin-top, try to remove margins from all around h2. i.e margin:0; I hope this will help you understanding the point.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...