简体   繁体   English

约4张图片的边框

[英]A border around 4 pictures

I'm making a website for my study and I want to make a newsblock. 我正在建立一个网站供我学习,我想制作一个新闻块。 Now i have 4 items: f1, tour, cultunair and theater. 现在我有4个项目:F1,巡回赛,cultairair和剧院。

<div id = "nieuws">
            <div id="nieuwstekst">Nieuws:</div>
                <a href="activiteiten.html" target="">
                    <div id="f1">
                        <img src="f1.jpg" alt="">
                            <div id="f1tekst">F1 terug naar zandvoort</div>
                            <div id="f1subtekst">Klik voor meer informatie</div>
                    </div>
                </a>    
                <a href="activiteiten.html" target="">
                    <div id="tour">
                        <img src="tour.jpg" alt="">
                        <div id="tourtekst">Tour de france 2016 door Haarlem</div>
                            <div id="toursubtekst">Klik voor meer informatie</div>
                    </div>
                </a>
                <a href="activiteiten.html" target="">
                    <div id="cultunair">
                        <img src="cultunair.jpg" alt="">
                            <div id="cultunairtekst">NIEUW: Cultunaire dag</div>
                            <div id="cultunairsubtekst">Klik voor meer informatie</div>
                    </div>
                </a>    
                <a href="activiteiten.html" target="">
                    <div id="theater">
                        <img src="theater.jpg" alt="">
                        <div id="theatertekst">Nederlands Theater Festival in Haarlem</div>
                            <div id="theatersubtekst">Klik voor meer informatie</div>
                    </div>
                </a>
        </div>

In my css i placed this pictures in two rows of two pictures: 在我的CSS中,我将此图片放置在两张图片的两行中:

#f1{
position: absolute; 
left: 1%;
top: 40%;
background-color: #000000;
border: 3px solid #000000;
border-radius:10px;
padding:3px 3px; 
}

#tour{
position: absolute; 
left: 26%;
top: 40%;
background-color: #000000;
border: 3px solid #000000;
border-radius:10px;
padding:3px 3px; 
}
#cultunair{
position: absolute; 
left: 1%;
top: 70%;

background-color: #000000;
border: 3px solid #000000;
border-radius:10px;
padding:3px 3px; 
}
#theater{
position: absolute; 
left: 26%;
top: 70%;
background-color: #000000;
border: 3px solid #000000;
border-radius:10px;
padding:3px 3px; 
}

But now I want to make in css a border in #nieuws around the four Items. 但是现在我想在CSS中的四个项目周围的#nieuws中创建边框。 Can anybody exlain me how to do that? 有人可以告诉我该怎么做吗?

I tried this, but that won't work: 我尝试了这个,但是那行不通:

#nieuws{
position: absolute; 
left: 1%;
top: 40%;
border: 3px solid #88bd32;
border-radius:10px;
padding:3px 3px; 
}

can anybody help me? 有谁能够帮助我?

Thanks a lot! 非常感谢!

It seems to me you can play with separate attributes border-right, border-left, border-top, border-bottom. 在我看来,您可以使用单独的属性来设置边框右,边框左,边框顶,边框底。 They have the same properties as border attribute. 它们具有与border属性相同的属性。 Eg: 例如:

.myclass {
border-right: 1px solid black;
border-left: none
}

Something like this? 像这样吗 Removes the positions, because your div's where floating around, and your main nieuws div not. 删除头寸,因为您的div左右浮动,而主要的div不在。

#f1 {
    left: 1%;
    top: 40%;
    background-color: #000000;
    border: 3px solid #000000;
    border-radius:10px;
    padding:3px 3px;
}
#tour {
    left: 26%;
    top: 40%;
    background-color: #000000;
    border: 3px solid #000000;
    border-radius:10px;
    padding:3px 3px;
}
#cultunair {
    left: 1%;
    top: 70%;
    background-color: #000000;
    border: 3px solid #000000;
    border-radius:10px;
    padding:3px 3px;
}
#theater {
    left: 26%;
    top: 70%;
    background-color: #000000;
    border: 3px solid #000000;
    border-radius:10px;
    padding:3px 3px;
}
#nieuws {
    left: 1%;
    top: 40%;
    border: 3px solid #88bd32;
    border-radius:10px;
    padding:3px 3px;
}

Fiddle here 在这里摆弄

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM