html - 在 CSS 中对齐容器

标签 html css xhtml

不幸的是,我对 CSS 的了解相当有限,我目前有一个主题,尽管我想要右手边的标题,例如Contact 和 About 靠右对齐,这样两个标题将始终显示在页面的右侧。

如有任何帮助,我将不胜感激,我已经在 CSS 中确定了容器 - “正确”

模板位于此处:

http://themeforest.net/item/cleanfolio-dark/22659

CSS 代码:

body {
    background: url(../images/bg.png) repeat;
    font: 12px Arial, Helvetica, Sans-Serif;
    padding: 0;
    margin: 0;
}

#container {
    width: 1165px;
}


/* ---- Standard Elements ---- */

a {
    color: #BBBBBB;
    text-decoration: none;
}

a:hover {
    color: #FFFFFF;
    text-decoration: none;
}

a:visited {
    text-decoration: none;
}

a:active {
    color: #FFFFFF;
    text-decoration: none;
}

h1, h2, h3, h4, h5 {
    font-family: Arial, Helvetica, Sans-Serif;
    font-weight: bolder;
    color: #FFFFFF;
    padding: 0;
    margin: 0px 0px 0px 0px;
}

h1 { font-size: 36px; }
h2 { font-size: 30px; }
h3 { font-size: 24px; }
h4 { font-size: 18px; }
h5 { font-size: 16px; }

p {
    line-height: 1.8em;
    padding: 0;
    margin: 0 0 5px 0;
}


/* ---- Header ---- */

#header {
    background: url(../images/blue/header_bg.png) repeat-x;
    height: 130px;
}

.header_title {
    float: left;
    background: url(../images/blue/header_titlebg.png);
    width: 370px;
    height: 110px;
    padding: 20px 0px 0px 30px;
}

.header_title h1 {
    font-size: 47px;
    font-weight: bolder;
    color: #FFFFFF;
    padding: 0;
    margin-bottom: -4px;
}

.header_title span {
    font-size: 10px;
    color: #71b3f0;
}


/* ---- Left Side Elements ---- */

#left {
    float: left;
    width: 840px;
    margin-right: 25px;
}

.portfolio_section-top {
    background: url(../images/topdivider.png) no-repeat;
    width: 790px;
    height: 280px;
    padding: 30px 10px 0px 30px;
}

.portfolio_section {
    background: url(../images/divider.png) no-repeat;
    width: 790px;
    height: 280px;
    padding: 30px 10px 0px 30px;
}

.portfolio_section-top img, .portfolio_section img {
    background: #111111;
    padding: 15px;
    border: 1px solid #222222;
}

.portfolio_section-top h1, .portfolio_section h1 {
    margin-bottom: 5px;
}

.portfolio_section-top small, .portfolio_section small {
    font: 10px Arial, Helvetica, Sans-Serif;
    color: #666666;
    text-transform: uppercase;
    line-height: 2em;
}

.portfolio_section-top p, .portfolio_section p {
    font: 12px Arial, Helvetica, Sans-Serif;
    color: #999999;
    margin-top: 10px;
    line-height: 1.8em;
}

.button_bg {
    background: url(../images/blue/button_bg.png) repeat-x;
    height: 14px;
    font: 10px Arial, Helvetica, Sans-Serif;
    color: #FFFFFF;
    text-transform: uppercase;
    padding: 5px 10px 5px 10px;
}

.tdmarginright td {
    padding-right: 30px;
}

.tdmarginright2 td {
    padding: 10px 17px 0px 0px;
}

.footer {
    margin-left: 30px;
    color: #666666;
}


/* ---- Right Side Elements ---- */

#right {
    float: right;
    width: 300px;
    margin-top: 30px;
}

.sidebar_title {
    background: url(../images/sidebar_titlebg.png);
    width: 283px;
    height: 38px;
    padding: 12px 0px 0px 17px;
}

.sidebar_bg {
    background: url(../images/sidebar_bg.png) repeat-y;
    width: 268px;
    color: #666666;
    padding: 0px 15px 15px 17px;
}

.sidebar_bottom {
    background: url(../images/sidebar_bottom.png) no-repeat;
    width: 300px;
    height: 1px;
    margin-bottom: 30px;
}

最佳答案

不知道这是否太明显了,但是——

CSS 看起来不错, 请注意它是#right——而不是 .right——所以很明显在你的 html 中你将使用 div id 而不是 div class

关于html - 在 CSS 中对齐容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7174542/

相关文章:

html - IE7中的水平滚动条

html - 出现错误 : UIInstructions cannot be cast to org. primefaces.model.menu.MenuElement

javascript - jquery window.load() 函数不会在 ios5 上触发

html - 为适应特定屏幕尺寸而更改时,表单 HTML 和 CSS 媒体查询出现 float 错误

php - 如何仅为特定用户角色添加 CSS?

css - 如何在同一行上排列图像

html - CSS3 动画过渡 : opacity not working

javascript - 使用 CSS 轻松地将不同的动画应用于特定的 div,如果不可能的话,使用 JS?

html - Flexbox 布局,难倒在标题部分

java - Primefaces 选择列表数据未从源传输到目标