关闭段落创建不需要的换行符

时间:2013-05-06 23:47:04

标签: css html paragraph

我正在努力使所有圆圈在整个页面上对齐,但它们是垂直堆叠的。有没有办法删除换行符,或任何其他工具,允许我的段落中的CSS具有相同的CSS属性?实现div会更容易吗?

<div>
    <p id="developer">
    <br>
    <br>
    <br>
    <br>
    HTML
    <br>
    CSS
    <br>
    JavaScript & jQuery
    </p>

    <p id="designer">
            <br>
    <br>
    <br>
    <br>
        Photoshop
        <br>
            Illustrator
            <br>
                Responsive Design
    </p>

    <p id="uxdesigner">
        <br>
    <br>
    <br>
    <br>
        Flowcharts
        <br>
            Wireframes
            <br>
                Personas
    </p>
</div>

#developer {
    background-color: #0071BC;
    width: 300px;
    height: 300px;
    border-radius: 300px;
    text-align: center;

}
#designer {
    background-color: #0071BC;
    width: 300px;
    height: 300px;
    border-radius: 300px;
    text-align: center; 
}
#uxdesigner {
    background-color: #0071BC;
    width: 300px;
    height: 300px;
    border-radius: 300px;
    text-align: center; 
}

2 个答案:

答案 0 :(得分:3)

添加:

p {
    display:inline-block;
}

作为旁注,请在CSS文件中保留布局,不要使用HTML元素。特别是用<br>创建间距是个坏主意和语义灾难。

答案 1 :(得分:0)

在这种情况下,您可以使用display: table获得额外的价值。这是一个更清洁的代码版本:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

<style media="all">

.skills {display: table;}
.skills p {
    display: table-cell; 
    vertical-align: middle; 
    background-color: #0071BC;
    width: 300px;
    height: 300px;
    border-radius: 300px;
    text-align: center;
    margin: 0;
}
.skills span {display: block;}

</style>

</head>
<body>

<div class="skills">
    <p>
        <span>HTML</span>
        <span>CSS</span>
        <span>JavaScript & jQuery</span>
    </p>

    <p>
        <span>Photoshop</span>
        <span>Illustrator</span>
        <span>Responsive Design</span>
    </p>

    <p>
        <span>Flowcharts</span>
        <span>Wireframes</span>
        <span>Personas</span>
    </p>
</div>

</body>
</html>