【问题标题】:html bootstrap cant align to centerhtml bootstrap 无法居中对齐
【发布时间】:2018-05-16 16:11:32
【问题描述】:

大家好,我是 Stackoverflow 的新手,我用 HTML 编码已经 5 个多月了。我目前正在使用 Boostrap。我目前正在尝试将this 网站修改为我喜欢的方式。但我似乎无法正确对齐,如this image 所示。如您所见,左侧空间较大,右侧空间较小。

我查看了其他存在类似问题的 Stackoverflow 帖子,并查看了 CSS 文件并尝试查找与边距相关的任何内容并对其进行修改,但我无法使其正常工作,因此我的部分正确居中。我正在使用 row 和 span12。

基本上我试图将部分 (<section id="projects">) 对齐到页面的中心

我希望有人可以帮助我。 P.S 网站的下载链接在哪里

http://www.alessioatzeni.com/blog/brushed-template/

非常感谢:)

更新 1 这是我的工作区。我没有修改css

<!-- Our Work Section -->
<div id="work" class="page">
    <div class="container">
        <div class="row">
            <div class="span12">
                <div class="title-page-less-margin">
                    <h2 class="title">Our Work</h2>
                    <h3 class="title-description">Check Out Our Projects on <a href="#">Dribbble</a>.</h3>

                </div>
            </div>
        </div>
        <!-- Portfolio Projects -->

        <div class="span12">
            <div class="row">

                <div class="title-page-less-margin">
                    <nav id="options" class="work-nav">

                        <ul id="filters" class="option-set" data-option-key="filter">
                            <a href="#filter" data-option-value="*" class="selected">All Projects</a>
                            <a href="#filter" data-option-value=".design">Design</a>
                            <a href="#filter" data-option-value=".photography">Photography</a><
                            <a href="#filter" data-option-value=".video">Video</a>
                        </ul>

                    </nav>
                </div>


                <section id="projects">
                    <ul id="thumbs">

                        <!-- Item Project and Filter Name -->
                        <li class="item-thumbs span3 design">
                            <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                            <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="The City" href="_include/img/work/full/image-01-full.jpg">

                                <span class="overlay-img"></span>
                                <span class="overlay-img-thumb font-icon-plus"></span>
                            </a>

                            <!-- Thumb Image and Description -->
                            <img src="_include/img/work/thumbs/image-01.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis. hihihi">
                        </li>
                        <!-- End Item Project -->

                        <!-- Item Project and Filter Name -->
                        <li class="item-thumbs span3 design">
                            <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                            <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="The Office" href="_include/img/work/full/image-02-full.jpg"></a>
                            <!-- Thumb Image and Description -->
                            <img src="_include/img/work/thumbs/image-02.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
                        </li>
                        <!-- End Item Project -->

                        <!-- Item Project and Filter Name -->
                        <li class="item-thumbs span3 photography">
                            <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                            <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="The Mountains" href="_include/img/work/full/image-03-full.jpg"></a>
                            <!-- Thumb Image and Description -->
                            <img src="_include/img/work/thumbs/image-03.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
                        </li>
                        <!-- End Item Project -->

                        <!-- Item Project and Filter Name -->
                        <li class="item-thumbs span3 video">
                            <!-- Fancybox Media - Gallery Enabled - Title - Link to Video -->
                            <a class="hover-wrap fancybox-media" data-fancybox-group="video" title="Video Content From Vimeo" href="http://vimeo.com/51460511"></a>
                            <!-- Thumb Image and Description -->
                            <img src="_include/img/work/thumbs/image-08.jpg" alt="Video">
                        </li>
                        <!-- End Item Project -->

                        <!-- Item Project and Filter Name -->
                        <li class="item-thumbs span3 photography">
                            <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                            <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="The Sea" href="_include/img/work/full/image-04-full.jpg"></a>
                            <!-- Thumb Image and Description -->
                            <img src="_include/img/work/thumbs/image-04.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
                        </li>
                        <!-- End Item Project -->

                        <!-- Item Project and Filter Name -->
                        <li class="item-thumbs span3 photography">
                            <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                            <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="Clouds" href="_include/img/work/full/image-05-full.jpg"></a>
                            <!-- Thumb Image and Description -->
                            <img src="_include/img/work/thumbs/image-05.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
                        </li>
                        <!-- End Item Project -->

                        <!-- Item Project and Filter Name -->
                        <li class="item-thumbs span3 video">
                            <!-- Fancybox Media - Gallery Enabled - Title - Link to Video -->
                            <a class="hover-wrap fancybox-media" data-fancybox-group="video" title="Video Content From Vimeo" href="http://vimeo.com/50834315"></a>
                            <!-- Thumb Image and Description -->
                            <img src="_include/img/work/thumbs/image-09.jpg" alt="Video">
                        </li>
                        <!-- End Item Project -->

                        <!-- Item Project and Filter Name -->
                        <li class="item-thumbs span3 design">
                            <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                            <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="The Dark" href="_include/img/work/full/image-06-full.jpg"></a>
                            <!-- Thumb Image and Description -->
                            <img src="_include/img/work/thumbs/image-06.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
                        </li>
                        <!-- End Item Project -->

                        <!-- Item Project and Filter Name -->
                        <li class="item-thumbs span3 design">
                            <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                            <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="The Beach" href="_include/img/work/full/image-07-full.jpg"></a>
                            <!-- Thumb Image and Description -->
                            <img src="_include/img/work/thumbs/image-07.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
                        </li>
                        <!-- End Item Project -->
                    </ul>
                </section>
            </div>
        </div>

        <!-- End Portfolio Projects -->


        <!-- End Title Page -->
    </div>
</div>

【问题讨论】:

  • 你想精确对齐什么?
  • @Srax 对不起,我应该提到这一点。我正在尝试对齐图像,以便 section 与 id projects
  • 能否提供HTML和CSS,方便帮助您。
  • 我修改了问题
  • 如果您能向我们提供您遇到问题的 HTML 和 CSS,会容易得多。我只能猜测您对链接的模板所做的更改:(

标签: html css twitter-bootstrap alignment


【解决方案1】:

用下面的代码替换整个&lt;div class="container"&gt;:
ps:我知道你不应该在 HTML 中编写 CSS,但这是我在我的电脑上没有 CSS 的情况下修复它的方式,你可以稍后将它移动到样式表中。

<div class="container">
    <!-- Title Page -->
    <div class="row" style="
       text-align: center;
       padding-bottom: 30px;
       ">
        <h2 class="title">Our Work</h2>
        <h3 class="title-description">Check Out Our Projects on <a href="#">Dribbble</a>.</h3>
        <div class="title-page-less-margin">
            <nav id="options" class="work-nav">

                <ul id="filters" class="option-set" data-option-key="filter">
                    <a href="#filter" data-option-value="*" class="selected">All Projects</a>
                    <a href="#filter" data-option-value=".design">Design</a>
                    <a href="#filter" data-option-value=".photography">Photography</a>&lt;
                    <a href="#filter" data-option-value=".video">Video</a>
                </ul>

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

    <div class="row">

        <section id="projects">
            <ul id="thumbs">

                <!-- Item Project and Filter Name -->
                <li class="item-thumbs span3 design">
                    <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                    <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="The City" href="_include/img/work/full/image-01-full.jpg">

                                <span class="overlay-img"></span>
                                <span class="overlay-img-thumb font-icon-plus"></span>
                            </a>

                    <!-- Thumb Image and Description -->
                    <img src="_include/img/work/thumbs/image-01.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis. hihihi">
                </li>
                <!-- End Item Project -->

                <!-- Item Project and Filter Name -->
                <li class="item-thumbs span3 design">
                    <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                    <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="The Office" href="_include/img/work/full/image-02-full.jpg"></a>
                    <!-- Thumb Image and Description -->
                    <img src="_include/img/work/thumbs/image-02.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
                </li>
                <!-- End Item Project -->

                <!-- Item Project and Filter Name -->
                <li class="item-thumbs span3 photography">
                    <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                    <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="The Mountains" href="_include/img/work/full/image-03-full.jpg"></a>
                    <!-- Thumb Image and Description -->
                    <img src="_include/img/work/thumbs/image-03.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
                </li>
                <!-- End Item Project -->

                <!-- Item Project and Filter Name -->
                <li class="item-thumbs span3 video">
                    <!-- Fancybox Media - Gallery Enabled - Title - Link to Video -->
                    <a class="hover-wrap fancybox-media" data-fancybox-group="video" title="Video Content From Vimeo" href="http://vimeo.com/51460511"></a>
                    <!-- Thumb Image and Description -->
                    <img src="_include/img/work/thumbs/image-08.jpg" alt="Video">
                </li>
                <!-- End Item Project -->

                <!-- Item Project and Filter Name -->
                <li class="item-thumbs span3 photography">
                    <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                    <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="The Sea" href="_include/img/work/full/image-04-full.jpg"></a>
                    <!-- Thumb Image and Description -->
                    <img src="_include/img/work/thumbs/image-04.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
                </li>
                <!-- End Item Project -->

                <!-- Item Project and Filter Name -->
                <li class="item-thumbs span3 photography">
                    <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                    <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="Clouds" href="_include/img/work/full/image-05-full.jpg"></a>
                    <!-- Thumb Image and Description -->
                    <img src="_include/img/work/thumbs/image-05.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
                </li>
                <!-- End Item Project -->

                <!-- Item Project and Filter Name -->
                <li class="item-thumbs span3 video">
                    <!-- Fancybox Media - Gallery Enabled - Title - Link to Video -->
                    <a class="hover-wrap fancybox-media" data-fancybox-group="video" title="Video Content From Vimeo" href="http://vimeo.com/50834315"></a>
                    <!-- Thumb Image and Description -->
                    <img src="_include/img/work/thumbs/image-09.jpg" alt="Video">
                </li>
                <!-- End Item Project -->

                <!-- Item Project and Filter Name -->
                <li class="item-thumbs span3 design">
                    <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                    <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="The Dark" href="_include/img/work/full/image-06-full.jpg"></a>
                    <!-- Thumb Image and Description -->
                    <img src="_include/img/work/thumbs/image-06.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
                </li>
                <!-- End Item Project -->

                <!-- Item Project and Filter Name -->
                <li class="item-thumbs span3 design">
                    <!-- Fancybox - Gallery Enabled - Title - Full Image -->
                    <a class="hover-wrap fancybox" data-fancybox-group="gallery" title="The Beach" href="_include/img/work/full/image-07-full.jpg"></a>
                    <!-- Thumb Image and Description -->
                    <img src="_include/img/work/thumbs/image-07.jpg" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
                </li>
                <!-- End Item Project -->
            </ul>
        </section>

    </div>
</div>

应该是这样的:

【讨论】:

  • 哇,不行!!!非常感谢。那么对于使用 row 或 span 的所有内容,我将如何解决它?因为现在除了项目之外没有什么是对齐的
  • 没问题,很高兴能帮上忙。不幸的是,编辑模板可能是一件非常痛苦的事情。你能试着把整个项目发给我吗?您可以在某处以 zip 的形式上传,然后将下载链接发送给我 :)
  • 给你drive.google.com/open?id=1aGTPj3ojSZeJNFkwHCx_K-_9Avf3rxAj 说真的老兄我很高兴你能帮助你不知道在我发布问题之前我试图修复它多久
  • 您是否正在修改 css 以使所有内容都正确对齐?
  • 我正在尝试,但它是一个真正的痛苦:(
猜你喜欢
  • 2013-02-22
  • 2020-11-29
  • 1970-01-01
  • 2012-04-27
  • 1970-01-01
  • 1970-01-01
  • 2017-06-03
  • 2017-11-14
相关资源
最近更新 更多