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
286 views
in Technique[技术] by (71.8m points)

javascript - How to make a div fit the whole width?

I want to make the div with class ".shadow" fit the whole width. But I am unable to figure it out. The code I am using is given bellow.

.main .container{
    margin: auto;
    display: table;
}

.main .main-inner{
    display: table-cell;
    vertical-align: middle;
    height: 100vh;
    text-align: center;
}

.shadow{
    background-color: rgba(0, 255, 0, 0.25);
}
<section class="main">
     <div class="container">
        <div class="main-inner">
            <div class="shadow">
                <img src="images/broadhurst.gif" alt="" class="logo-img">
                <ul>
                    <li><a href="glenn-broadhurst.html">Glenn Broadhurst</a></li>//
                    <li><a href="#">Demand Calculator</a></li>//
                    <li><a href="clock.html">The Clock</a></li>
                </ul>
            </div>
        </div>
     </div>
    </section> 

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

1 Reply

0 votes
by (71.8m points)

By the whole width, you mean the whole page? if that's what you want then

.shadow{background-color: rgba(0, 255, 0, 0.25); width:100%;position:absolute}

is what you're looking for Edit: Oh, and don't forget to add width:100% to the other elements too


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

...