向左移动div - bootstrap

时间:2017-12-03 15:40:15

标签: html css twitter-bootstrap

我有这段代码建立在bootstrap和字体上很棒,我想把时钟向左移动一点,所以它在中间位于中间位置。 哪个是最佳解决方案,因此它对所有设备都有响应?

HTML

<div class="clock col-md-12 col-sm-12">
        <i class="fa fa-clock-o fa-spin fa-4x fa-clock-spin x1"></i>
    </div>

CSS

.clock {
    text-align:center;
    position:relative;
    line-height:100px;
    margin-bottom:5px;
	margin-right: 300px;
}

.x1 {
    font-size: 3vw !important;
    position: fixed;
    z-index: 0;
}

2 个答案:

答案 0 :(得分:0)

您可以向flexbox ...

添加一些.clock属性

.clock {
  display: flex;
  justify-content: center;
}

.x1 {
  font-size: 3vw !important;
  position: fixed;
  z-index: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="clock col-md-12 col-sm-12">
  <i class="fa fa-clock-o fa-spin fa-4x fa-clock-spin x1"></i>
</div>

答案 1 :(得分:0)

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link rel="stylesheet" href="">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href="https://fonts.googleapis.com/css?family=Work+Sans:400,500,600,700" rel="stylesheet">

<style>
    .ticktok {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}   
</style>
</head>
<body>

           <div class="container">
            <div class="row">
                <i class="fa fa-clock-o fa-4 fa-clock-spin ticktok" aria-hidden="true"></i>
            </div>
           </div>

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</body>
</html>