0

很抱歉这个菜鸟和愚蠢的问题,但我对 css 知之甚少,我不知道如何设计我的网站。这是我的代码:

HTML(树枝):

<div class="wrap">
    <div>
        <img class="birthday" src="http://www.clker.com/cliparts/1/d/a/6/11970917161615154558carlitos_Balloons.svg.med.png">
            <div class="try"> 
               This friends have brithday today: 
               {% for bd in birthdays %}

               <p>
                   <a href="{{ path('friend_id', {'id': bd.id}) }}">{{ bd.name }}</a>
                      <span class="years">
                         ({{ bd.years }} years)
                       </span>
               </p>

               {% endfor %}

            </div>

    </div>
</div>

CSS:

body {
    background-color: #FFFFF1;
    text-align: center;
    font-size: 17px;
    font-family: Tahoma, Geneva, sans-serif;  
}

p {
    margin: 10px;
}

a {
    text-decoration: none;
    color: #6a9211;
}

a:hover {
    text-decoration: underline;
}

.wrap {
    width: 700px;
    margin: auto;
}

.birthday {
    width: 49px;
    height: 80px;
    float: left;
    margin-left: 150px;
    display: block;  
}

.try {
    display: block;
    margin-right: 150px;
    margin-bottom: 50px;
}

.years {
    font-size: 12px;
}

就是我得到的。我要解决的问题是MariaPeter显示在Annaand下John,所有这些都 4 在标签下居中This friends have birthday today:。我知道这是因为图像,但我不知道如何使它看起来很好。:(

请帮忙!提前致谢!

4

4 回答 4

2

仅 CSS小提琴-

添加float: right;.try课堂 -

.try {
    /*display: block;*/ float: right;
    margin-right: 150px;
    margin-bottom: 50px;
}

编辑:

您还可以删除margins和管理 div width-

.try {
    /*display: block;*/ float: right; width: 500px;
    /*margin-right: 150px;
    margin-bottom: 50px;*/
}

更新小提琴

于 2012-08-30T09:31:01.013 回答
2

试试这个:

.try {
width: 500px;
float: right;
margin-right: 150px;
margin-bottom: 50px;
}
于 2012-08-30T09:34:31.310 回答
1

你只需要在try-class中添加一些margin-left:http: //jsfiddle.net/VWY8N/

.try {
    display: block;
    margin-right: 150px;
    margin-bottom: 50px;
    margin-left: 201px;
}
于 2012-08-30T09:30:33.647 回答
-1

将您的 css 添加到 head 部分的样式标记中,如下所示

<html>
<head>
<style>
{
    background-color: #FFFFF1;
    text-align: center;
    font-size: 17px;
    font-family: Tahoma, Geneva, sans-serif;  
}

p {
    margin: 10px;
}

a {
    text-decoration: none;
    color: #6a9211;
}

a:hover {
    text-decoration: underline;
}

.wrap {
    width: 700px;
    margin: auto;
}

.birthday {
    width: 49px;
    height: 80px;
    float: left;
    margin-left: 150px;
    display: block;  
}

.try {
    display: block;
    margin-right: 150px;
    margin-bottom: 50px;
}

.years {
    font-size: 12px;
}

</style>
</head>
<body>
<div class="wrap">
    <div>
        <img class="birthday" src="http://www.clker.com/cliparts/1/d/a/6/11970917161615154558carlitos_Balloons.svg.med.png">
            <div class="try"> 
               This friends have brithday today: 
               {% for bd in birthdays %}

               <p>
                   <a href="{{ path('friend_id', {'id': bd.id}) }}">{{ bd.name }}</a>
                      <span class="years">
                         ({{ bd.years }} years)
                       </span>
               </p>

               {% endfor %}

            </div>

    </div>
</div>

</body>
</html>
于 2012-08-30T09:30:36.180 回答