css - 如何解决div定位问题

标签 css html responsive-design

我这里有一个测试站点:

http://www.hugoproject.com/test.html

我正在尝试将第二行书籍图标放在第一行下方,但无论我尝试什么都行不通。以下代码使单个书本图标出现:

<div class="project">
<a href="#" class="HS" class="project-link">Arrow<span></span></a>
</div>

当我有两套代码时,出现两个图标,当有三套代码时,出现三个图标。但是,如果我有四组或更多组代码,仍然只会出现三个图标。我需要额外的代码集来制作前三个图标下方的图标。

同样在您调整浏览器窗口大小时,这会使图标动态调整大小。我想保留此功能并使两行图标都适合一页,这样就没有滚动条了。

有什么想法吗?

HTML

<div id="content">
<div id="home-projects-wrapper">

<h1 class="home">Hello! My name is Brandon</h1>

<div id="home-projects">
<div id="projects" class="circle">
<div class="project-group">

<div class="project">
<a href="#" class="HS" class="project-link">Arrow<span></span></a>
</div>

<div class="project">
<a href="#" class="HS" class="project-link">Arrow<span></span></a>
</div>
                                           <div class="project">
<a href="#" class="HS" class="project-link">Arrow<span></span></a>
</div>

<div class="project">
<a href="#" class="HS" class="project-link">Arrow<span></span></a>
</div>

</div>
</div>
</div>
</div>
</div>

CSS

#container {
    transition: left .3s;
    -moz-transition: left .3s;
    -webkit-transition: left .3s;
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    overflow-x: hidden;
}
#container.open {
    left: 270px;
    position: absolute;
    width: 100%;
    height: 100%;
    transition: left .3s;
    -moz-transition: left .3s;
    -webkit-transition: left .3s;
    overflow-x: hidden;
}
#content {
    width: 80%;
    max-width: 1170px;
    margin: 7% auto;
    position: relative;
    font-size: 14px;
    line-height: 22px;
    color: #777777;
}
.page-template-page-templateshome-php #content {
    width: auto;
    margin: 0 auto;
    position: static;
}
.single-post #content { width: 60% }
#home-projects {
    text-align: center;
    overflow: hidden;
    position: relative;
}
#projects { width: 100% }
.project-group {
    width: 100%;
    height: 100%;
    position: absolute;
}
.project {
    float: left;
    text-align: center;
    width: 33.3%;
    height: 100%;
}
.project-link {
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    background-color: #adadad;
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 80%;
}
.circle .project-link,
.circle .project-link .hover {
    border-radius: 100%;
    -moz-border-radius: 100%;
    -webkit-border-radius: 100%;
}
.project-link .hexagon-top {
    content: '';
    display: block;
    position: absolute;
    left: 0;
    border-style: solid;
    border-bottom-color: transparent;
    border-left-color: #dfdfdf;
    border-right-color: #dfdfdf;
    width: 0;
    height: 0;
    z-index: 2;
}
.project-link .hexagon-bottom {
    content: '';
    display: block;
    position: absolute;
    left: 0;
    bottom: 0;
    border-style: solid;
    border-top-color: transparent;
    border-left-color: #dfdfdf;
    border-right-color: #dfdfdf;
    width: 0;
    height: 0;
    z-index: 2;
}
.project-link .hover {
    position: absolute;
    width: 100%;
    height: 100%;
    font-size: 14px;
    text-align: center;
    color: #fff;
    background: #ec6136;
    text-decoration: none;
    text-transform: uppercase;
    display: block;
    opacity: 0;
    transition: all .3s;
    -moz-transition: all .3s;
    -webkit-transitin: all .3s;
}
.project-link .hover-text {
    display: block;
    margin-top: 45%;
}
.project-link .hover-text:after {
    content: '>';
    font-family: 'icon';
    font-size: 12px;
    margin-left: 15px;
}
.project-link:hover > .hover { opacity: .9 }

最佳答案

它看起来像在你的 css (style.css) 中你有这个:

.project-group{
    width: 100%;
    height: 100%;
    position: absolute;
}

只需将绝对值切换为相对值,您的第二行就会出现。够了吗?

.project-group{
    width: 100%;
    height: 100%;
    position: relative;
}

关于css - 如何解决div定位问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18151283/

相关文章:

responsive-design - 将 jquery isotope 与 Foundation 集成

javascript - 砌体布局(有时)在元素之间添加 1px 间距

css - 嵌套 CSS 元素(在标题中设置链接样式)

javascript - jQuery 如何在输入字段为空时禁用点击功能

html - nth-child 定位所有子元素

css - 如何使 Canvas 响应

html - 在 html 中,使一个 div 的宽度固定,另一个 div 的宽度应根据窗口大小动态减小

css - 使用 Bootstrap 将元素静态放置在跨度元素的底部

php - 尝试将 PHP header 与 IFrame 一起使用

html - 语义正确的 XHTML 标记