无法将图像或文本居中

时间:2016-07-12 14:16:28

标签: javascript html css

我正在为自己创建一个投资组合网站,但我最近为部门工作的项目和公司应该以中心为主,但我不能让它们居中。

如何修复代码?我对技术编程词不太满意。

HTML:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="assets/img/favicon.ico">

    <title>Jacob Lane - Portfolio</title>

    <!-- Bootstrap core CSS -->
    <link href="assets/css/bootstrap.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="assets/css/ionicons.min.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">


    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="assets/js/ie10-viewport-bug-workaround.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>

    <div id="h">
        <div class="logo">
            <h2>PHOTOGRAPHY</h2>
        </div>
        <!--/logo-->
        <div class="container centered">
            <div class="row">
                <div class="col-md-8 col-md-offset-2">
                    <h1>Hello, my name is <b>Jacob Lane</b>.<br/>Enjoy. :)</h1>
                </div>
            </div>
            <!--/row-->

            <div class="row mt">
                <div class="col-sm-4">
                    <i class="ion-ios7-copy-outline"></i>
                    <h3>Secure Photos</h3>
                </div>
                <!--/col-md-4-->

                <div class="col-sm-4">
                    <i class="ion-monitor"></i>
                    <h3>Professionally Edited</h3>
                </div>
                <!--/col-md-4-->

                <div class="col-sm-4">
                    <i class="ion-camera"></i>
                    <h3>Professionally Taken</h3>
                </div>
                <!--/col-md-4-->

            </div>
            <!--/row-->
        </div>
        <!--/container-->
    </div>
    <!--H-->

    <div class="container ptb">
        <div class="row">
            <h2 class="centered mb"><b>My Gear:</b></h2>
            <div class="col-md-6">
                <p>To get the best shot in all photos, I use high-quality gear to make sure your memories can last a lifetime. Memories are an extraordinary thing to keep in your lifetime so using the best high-quality gear out it is good for what I offer.</p>
            </div>
            <!--/col-md-6-->
            <div class="col-md-6">
                <p>You can book a trial session or an event session below in the contact my area. Alternatively, you can see the feedback from I have gotten from past customers to get a realistic view of how good my gear can make memories last.</p>
            </div>
            <!--/col-md-6-->
        </div>
        <!--/row-->
    </div>
    <!-- /.container -->
    <div class="container" id="j">
        <div class="row">
                <p class="text-align-center"><strong>My Camera</strong>, Known for its ablilty to have a good photo, the Canon EOS 1200D has a stunning lens to capture high definition moments. I use this camera as it is capable of taking stunning high definition photo's for those
                    beautiful moments in life.</p>
                <a href="https://www.amazon.co.uk/Canon-1200D-Digital-Camera-3-5-5-6/dp/B00IE3UR08/ref=sr_1_1?ie=UTF8&qid=1468269724&sr=8-1&keywords=canon+eos+1200+d" target="_blank">Canon EOS 1200D</a>
                <p class="text-align-center"><strong>My Lens</strong>, The Lengs on the camera help the camera become more high definition and let me create more stunning zoomed in shots when needed.</p>
                <a href="https://www.amazon.co.uk/Canon-EF-S-18-55mm-3-5-5-6-Zoom/dp/B00BXVR97M/ref=sr_1_2?ie=UTF8&qid=1468269951&sr=8-2&keywords=18-55mm+lens+canon" target="_blank">Canon EF-S 18-55mm f/3.5-5.6 IS STM Zoom Lens</a> //\\ <a href="https://www.amazon.co.uk/Canon-75-300mm-4-0-5-6-III-Lens/dp/B00005K47Y">Canon EF 75-300mm f/4.0-5.6 III Lens</a>
                <p class="text-align-center"><strong>My Tripod</strong>, The allows me to be at the right comfortable height when I am taking photos, it also allows me to take pictures more stable so that the focus is better.</p>
                <a href="https://www.amazon.co.uk/VELBON-EF-51-DIGITAL-CAMERA-TRIPOD/dp/B019ZWAA1M/ref=sr_1_1?ie=UTF8&qid=1468270490&sr=8-1&keywords=Velbon+EF+-61+tripod" target="_blank">Velbon EF -61 Tripod</a>
            <!--/col-md-6-->
        </div>
        <!--/row-->
    </div>
    <!--/.container-->

    <div id="g">
        <div class="container">
            <div class="row centered">
                <h2>Past work:</h2>
                <div class="col-md-8 col-md-offset-2">
                    <p>Here are some pass work that I have been allowed to put up :)</p>
                </div>
                <!--/col-md-8-->
            </div>
            <!--/row-->
        </div>
        <!--/.container-->
        <div class="portfolio-centered mt">
            <div class="recentitems portfolio">
                <div class="portfolio-item graphic-design">
                    <div class="he-wrap tpl6">
                        <img src="assets/img/portfolio/portfolio_09.jpg" class="img-responsive" alt="">
                        <div class="he-view">
                            <div class="bg a0" data-animate="fadeIn">
                                <h3 class="a1" data-animate="fadeInDown">Motorbikes</h3>
                                <a data-rel="prettyPhoto" href="assets/img/portfolio/portfolio_09.jpg" class="dmbutton a2" data-animate="fadeInUp"><i class="ion-search"></i></a>
                                <a href="single-project.html" class="dmbutton a2" data-animate="fadeInUp"><i class="ion-link"></i></a>
                            </div>
                            <!-- he bg -->
                        </div>
                        <!-- he view -->
                    </div>
                    <!-- he wrap -->
                </div>
                <!-- end col-12 -->
            </div>
            <!-- portfolio -->
        </div>
        <!-- portfolio container -->

        <div class="container mt">
            <div class="row clients centered">
                <p class="mb">Some clients that I had the pleasure to working for.</p>
                <div class="col-sm-2 col-sm-offset-1">
                    <a href="http://racingwithbrad.com/" target="_blank"><img src="assets/img/client1.png" alt=""></a>
                </div>
            </div>
            <!--/row-->
        </div>
        <!--/container-->
    </div>
    <!--/.G-->

    <div id="sep">
        <div class="container">
            <div class="row centered">
                <div class="col-md-8 col-md-offset-2">
                    <h1>I live in the amazing United Kingdom</h1>
                    <h3 class="mb">Click the button below to request prices and information about me.</h3>
                    <a href=""><button class="btn btn-conf btn-clear">Request for Information</button></a>
                </div>
            </div>
            <!--/row-->
        </div>
        <!--/container-->
    </div>
    <!--/.sep-->

    <div id="f">
        <div class="container">
            <div class="row centered">
                <div class="col-md-8 col-md-offset-2">
                    <p class="white">
                        Copyright © 2016 Jacob Lane Photography.
                    </p>
                </div>
                <!--/col-md-8-->
            </div>
        </div>
        <!--/container-->
    </div>
    <!--/.F-->

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="assets/js/jquery.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script src="assets/js/retina-1.1.0.js"></script>
    <script src="assets/js/jquery.hoverdir.js"></script>
    <script src="assets/js/jquery.hoverex.min.js"></script>
    <script src="assets/js/jquery.prettyPhoto.js"></script>
    <script src="assets/js/jquery.isotope.min.js"></script>
    <script src="assets/js/custom.js"></script>


    <script>
        // Portfolio
        (function($) {
            "use strict";
            var $container = $('.portfolio'),
                $items = $container.find('.portfolio-item'),
                portfolioLayout = 'fitRows';

            if ($container.hasClass('portfolio-centered')) {
                portfolioLayout = 'masonry';
            }

            $container.isotope({
                filter: '*',
                animationEngine: 'best-available',
                layoutMode: portfolioLayout,
                animationOptions: {
                    duration: 750,
                    easing: 'linear',
                    queue: false
                },
                masonry: {}
            }, refreshWaypoints());

            function refreshWaypoints() {
                setTimeout(function() {}, 1000);
            }

            $('nav.portfolio-filter ul a').on('click', function() {
                var selector = $(this).attr('data-filter');
                $container.isotope({
                    filter: selector
                }, refreshWaypoints());
                $('nav.portfolio-filter ul a').removeClass('active');
                $(this).addClass('active');
                return false;
            });

            function getColumnNumber() {
                var winWidth = $(window).width(),
                    columnNumber = 1;

                if (winWidth > 1200) {
                    columnNumber = 5;
                } else if (winWidth > 950) {
                    columnNumber = 4;
                } else if (winWidth > 600) {
                    columnNumber = 3;
                } else if (winWidth > 400) {
                    columnNumber = 2;
                } else if (winWidth > 250) {
                    columnNumber = 1;
                }
                return columnNumber;
            }

            function setColumns() {
                var winWidth = $(window).width(),
                    columnNumber = getColumnNumber(),
                    itemWidth = Math.floor(winWidth / columnNumber);

                $container.find('.portfolio-item').each(function() {
                    $(this).css({
                        width: itemWidth + 'px'
                    });
                });
            }

            function setPortfolio() {
                setColumns();
                $container.isotope('reLayout');
            }

            $container.imagesLoaded(function() {
                setPortfolio();
            });

            $(window).on('resize', function() {
                setPortfolio();
            });
        })(jQuery);
    </script>
</body>

</html>

CSS:

/*  ################################################################
    1. GENERAL STRUCTURES
################################################################# */

/* Import fonts */
@import url(http://fonts.googleapis.com/css?family=Roboto:300,400,700,900);

@import url("prettyPhoto.css") screen;
@import url("hoverex-all.css") screen;

/* cyrillic-ext */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400;
  src: local('Roboto'), local('Roboto-Regular'), url(http://fonts.gstatic.com/s/roboto/v15/ek4gzZ-GeXAPcSbHtCeQI_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2');
  unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F;
}
/* cyrillic */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400;
  src: local('Roboto'), local('Roboto-Regular'), url(http://fonts.gstatic.com/s/roboto/v15/mErvLBYg_cXG3rLvUsKT_fesZW2xOQ-xsNqO47m55DA.woff2) format('woff2');
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

* {
    margin: 0;
    padding: 0px;
    font-family: 'Roboto', sans-serif;
}
body {
    background: #fff;
    margin: 0;
    color: #5a5a5a;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Roboto', sans-serif;
    font-weight: 300;
}


p {
    padding: 0;
    margin-bottom: 12px;
    font-family: 'Roboto', sans-serif;
    font-weight: 300;
    font-size: 18px;
    line-height: 28px;
    color: #666;
    margin-top: 10px;
}

html,
body {
    height: 100%;
}

.alignleft { float: left; }
.alignright { float: right; }
.aligncenter {
    margin-left: auto;
    margin-right: auto;
    display: block;
    clear: both;
}
.centered {text-align: center}
.mt {margin-top: 50px;}
.mb {margin-bottom: 50px;}
.mtb {margin-top: 50px; margin-bottom: 50px;}
.mtb2 { margin-top: 100px; margin-bottom: 100px;}
.ptb {padding-top: 80px; padding-bottom: 80px;}

.clear {
    clear: both;
    display: block;
    font-size: 0;
    height: 0;
    line-height: 0;
    width:100%;
}
::-moz-selection  {
    color: #fff;
    text-shadow:none;
    background:#2B2E31;
}
::selection {
    color: #fff;
    text-shadow:none;
    background:#2B2E31;
}
*,
*:after,
*:before {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}
a {
    padding: 0;
    margin: 0;
    text-decoration: none;
    -webkit-transition: background-color .4s linear, color .4s linear;
    -moz-transition: background-color .4s linear, color .4s linear;
    -o-transition: background-color .4s linear, color .4s linear;
    -ms-transition: background-color .4s linear, color .4s linear;
    transition: background-color .4s linear, color .4s linear;
    color: #1abc9c;
}
a:hover,
a:focus {
  text-decoration: none;
  color:#696E74;
}

.nopadding {
    padding: 0px !important;
    margin: 0px;
}


/* FORM CONFIGURATION */

input {
    font-size: 16px;
    min-height: 40px;
    border-radius: 2px;
    line-height: 20px;
    padding: 11px 30px 12px;
    border: 1px solid #b9b9af;
    margin-bottom: 10px;
    background-color: #fff;
    -webkit-transition: background-color 0.2s;
    transition: background-color 0.2s;
}

.white {
        color: #fff;
}

.subscribe-input {
    float: left;
    width: 65%;
    text-align: left;
    margin-right: 2px;
}

.subscribe-submit {
    right: 0;
}

.btn-download {
    background: #FDE3A7;
}

.btn-conf {
    border-radius: 50px;
    margin-right: 15px;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 14px 28px 13px 28px;
    }

.btn-clear {
    background: transparent;
    color: white;
    border: 2px solid white;
}
.btn-clear:hover {
    background: white;
    color: #2f2f2f;
}



.dmbutton:hover,
.dmbutton:active,
.dmbutton:focus{
    color: #ffffff;
    background-color: #222222;
    border-color: #ffffff;
}
.dmbutton {
    background:rgba(0, 0, 0, 0);
    border: 1px solid #ffffff;
    color: #ffffff;
    -webkit-border-radius: 2px;
    border-radius: 2px;
    padding-top: 1.025rem;
    padding-right: 2.25rem;
    letter-spacing:0.85px;
    padding-bottom: 1.0875rem;
    padding-left: 2.25rem;
    font-size: 1.55rem;
    cursor: pointer;
    font-weight: normal;
    line-height: normal;
    margin: 0 0 1.25rem;
    text-decoration: none;
    text-align: center;
    display: inline-block;
    -webkit-transition: background-color 300ms ease-out;
    -moz-transition: background-color 300ms ease-out;
    transition: background-color 300ms ease-out;
    -webkit-appearance: none;
    font-weight: normal !important;
}

/* HEADER SECTION */
#h {
    background: url(../img/header.jpg) no-repeat center top;
    padding-top: 5px;
    background-attachment: relative;
    background-position: center center;
    min-height: 700px;
    width: 100%;

    -webkit-background-size: 100%;
    -moz-background-size: 100%;
    -o-background-size: 100%;
    background-size: 100%;

    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    color: white;
}

#h .logo {
    margin-top: 30px;
    margin-left: 40px;
    padding-bottom: 150px;
}

#h .logo h3{
    font-weight: 900;
    color: white;
    letter-spacing: 1px;
}

#h3 {
    font-weight: 900;
    color: white;
    letter-spacing: 1px;
}

#h .logo h2{
    font-weight: 900;
    color: white;
    letter-spacing: 1px;
}

#h h3 {
    margin-top: 10px;
}

#h i {
    font-size: 50px;
}

#j {
    padding-bottom: 50px;
}

/* GREY SECTION */
#g {
    padding-top: 50px;
    padding-bottom: 50px;
    background: #f5f5f5;
}

.portfolio {
    padding:0 !important;
    margin:0 !important;
    display:block;
}


.portfolio-item .title:before {border-radius:0; display:none}
.portfolio-item p {margin:0px 0 30px;}
.portfolio-item h3 {margin:-10px 0 10px; font-size:16px; text-transform:uppercase;}


.tpl6 h3
{
    color:#fff;
    margin:0;
    padding:40px 5px 0;
    font-size:16px;
    text-transform:uppercase;
}
.tpl6 .dmbutton
{
    display:inline-block;
    margin:30px 5px 20px 5px;
    font-size:13px;
}

.tpl6 .bg
{
    height:100%;
    width:100%;
    background-color:#673AB7;
    background-color:rgba(103,58,183,.9);
    text-align:center;
}

/* CLIENTS */

.clients img {
    max-width: 140px;
    max-height: 60px;
    vertical-align: middle;
}

.clients .col-sm-2 {
    height: 80px;
    line-height: 80px;
}

/* CONTACT SEPARATOR */
#sep {
    background: url(../img/sep.jpg) no-repeat center top;
    padding-top: 100px;
    background-attachment: relative;
    background-position: center center;
    min-height: 450px;
    width: 100%;
    color: white;

    -webkit-background-size: 100%;
    -moz-background-size: 100%;
    -o-background-size: 100%;
    background-size: 100%;

    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    color: white;
}

#sep h3 {
    font-weight: 300;
    letter-spacing: 2px;
}

/* FOOTER */
#f {
    padding-top: 25px;
    padding-bottom: 25px;
    background-color: #673AB7;
}

#f i {
    margin-right: 30px;
    font-size: 35px;
}

#f a {
    color: white;
}

/* HEADER 2 - PORTFOLIO SECTION */
#h2 {
    background: url(../img/header-2.jpg) no-repeat center top;
    padding-top: 5px;
    background-attachment: relative;
    background-position: center center;
    min-height: 700px;
    width: 100%;

    -webkit-background-size: 100%;
    -moz-background-size: 100%;
    -o-background-size: 100%;
    background-size: 100%;

    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    color: white;
}

#h2 .logo {
    margin-top: 30px;
    margin-left: 40px;
    padding-bottom: 150px;
}

#h2 .logo h2{
    font-weight: 900;
    color: white;
    letter-spacing: 1px;
}

#h2 h3 {
    margin-top: 30px;
    letter-spacing: 1px;
}

2 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情:

$scope.search = function(typeContrat, ville, competence){
      $state.go('app.jobsList',{typeContrat:typeContrat,ville:ville,competence:competence});
    };

答案 1 :(得分:-3)

我不明白你的问题,

你可以在css中创建一个名为中心的类:

.centered {
position: absolute;
left: 50%;
margin-left: -100px;
}    
在CSS文件中你必须放一个。在班级名称之前

然后在你想要居中的标签下的html文件中添加该类,例如在想要居中的图像内部或文本

你想要居中,你可以通过参考你做的那个课

< p class = centered>

或者您可以使用想要居中的段落周围的中心标记

<center> <p> paragraph <p> <center>