小编Tim*_*Tim的帖子

Div Not Center在Bootstrap中使用class ="center-block"

我想做一个河内塔.

我想把控制部分放在中心,所以我检查了Bootstrap并使用class="center-block",但没有任何工作,如下:没有中心http://wuzhiwei.net/problems/no-center.png

演示.

HTML

<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading">Hanoi Tower</div>
        <div class="panel-body">
            <canvas id="stage" class="center-block" width="400" height="220" style="border:1px black solid "></canvas>
            <div id="ctrl" class="center-block">
                <label for="numsel">Disc Number?</label>
                <select id="numsel">
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    <option value="6">6</option>
                </select>
                <button class="btn btn-default" id="start" value="start">Start</button>
                <label for="step">Step?</label> <span class="badge" id="step">0</span>  

            </div>
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

.panel {
    min-width:400px;
}
#stage {
    margin-bottom:15px;
}
#start {
    margin-left:20px;
    margin-right:20px;
}
Run Code Online (Sandbox Code Playgroud)

Quesition

如何让这个div <div id="ctrl" class="center-block">居中?

html javascript css twitter-bootstrap

31
推荐指数
1
解决办法
6万
查看次数

Is there an efficient and elegant way to truncate number like this in Lua?

What I want to do

What I want to do is really simple. I want use Lua to check lines in a Plist file.

Let's say if a line in Plist, is <integer>-1.00</integer>, I need to cut the .00 off to make it be <integer>-1</integer>.

What I did

I use a function to read the whole file content and do line by line check and replace.

local function doLineClean( cont )
    newcont = ''
    string.gsub( cont, "(.-)\r?\n", function(line) …
Run Code Online (Sandbox Code Playgroud)

lua lua-patterns

4
推荐指数
1
解决办法
614
查看次数

在Python中获得相对路径的任何优雅方法?

假设我要在'Core.dll'之后删除'git pull',所以我写了一个钩子。

import os

dir = os.path.dirname(__file__)
try:
    os.remove(os.path.abspath(dir+os.sep+".."+os.sep+".."+os.sep+"Assets"+os.sep+"Plugins"+os.sep+"Core.dll"))

except OSError:
    pass
Run Code Online (Sandbox Code Playgroud)

假设挂钩路径为'E:\client\.git\hooks',我要删除的文件位于'E:\client\Assets\Plugins\Core.dll'.

我认为我的方法很愚蠢,是否有任何优雅的方法来获得相对路径?

python

4
推荐指数
1
解决办法
1878
查看次数

如何在javascript类中添加方法?

我怎么能把setPosition放在类中DrawClockHand?是DrawCLockHand即使在Javascript技术的一类.

码:

var DrawClockHand = function(cv) {
    this._cv = cv;
    this._ctx = cv.getContext('2d');
    this.TIME = 1000;
    this._r = 50;
}

DrawClockHand.prototype.setPosition = function(x,y) {
    x = x || 0;
    y = y || 0;
    this._x = x;
    this._y = y;
}
Run Code Online (Sandbox Code Playgroud)

javascript

0
推荐指数
1
解决办法
52
查看次数

标签 统计

javascript ×2

css ×1

html ×1

lua ×1

lua-patterns ×1

python ×1

twitter-bootstrap ×1