最近我一直在学习flexbox以及如何制作自己的网格系统。在使用浮点数制作网格系统时,我们确定每个布局的列数和每列的宽度(以百分比表示)。但是当使用flexbox时,我看到的所有布局教程都只是使用import datetime
import logging
from flask import Flask, request
app = Flask(__name__)
def testuser(username):
# show the user profile for that user
user_string = username.lower()
return 'Username you appended is %s' %user_string
@app.route('/user/', methods=['GET', 'POST'])
def show_user_profile():
# show the user profile for that user : http://127.0.0.1:8080/user/?user=gerry
uid = request.args.get('user')
print(testuser(uid))
return 'User %s' %uid
if __name__ == '__main__':
# This is used when running locally. Gunicorn is used to run the
# application on Google App Engine. See entrypoint in app.yaml.
app.run(host='127.0.0.1', port=8080, debug=True)
# [END app]
和flex-direction: row;
对于列,使所有这些相同的大小,相同的装订线,居中和一行。但是当我在github上检查flexboxgrid源代码时,它们使用与bootstrap 3相同的原理。它们具有不同屏幕大小的列,12列和flex: 1
,flex-grow
被禁用。相反,每列都以宽度百分比确定,例如shrink
col-xs-1
。
现在我想知道这两种技术之间的区别是什么,哪种更为可取。我的意思是确定每列的宽度需要大量计数,而使用flex grow属性只需在主轴上实现整个视口,同样大小的列和排水沟。
答案 0 :(得分:1)
<强> TL;博士强>
它们不是达到相同结果的技术,它们做不同的事情。
Flexbox grid使用flex-basis
确定Flex容器主轴中的width
。它不会对flex项使用flex: 1;
,因为它等同于flex: 1 1 0;
。这意味着flex-basis
的值为0
,并且弹性项目大小将与指定的增长和收缩因子成比例,两者的值均为1
。
示例强>
{p>col-xs-1
0
指定flex: 1;
的{{1}},如果是唯一的子项,则会col-xs-12
增长,如果还有另一个col-xs-1
col-xs-6
col-xs-1
1}}像这样的兄弟姐妹,它会像1/12
那样生长,等等。
预计每个flex: 1;
填充容器的* {
box-sizing: border-box;
}
article {
margin-bottom: 1rem;
}
[class^="col-"],
[class*="col-"] {
flex: 0 0 auto; /* flex-grow: 0; flex-shrink: 0; flex-basis: auto; */
}
.row {
display: flex;
margin-right: -.5rem;
margin-left: -.5rem;
}
.col-xs-1 {
padding-right: .5rem;
padding-left: .5rem;
flex-basis: 8.33333333%;
}
.box-row {
min-height: 1em;
background: #007FFF;
}
article:last-of-type .col-xs-1 {
flex: 1; /* Same as flex: 1 1 0; */
}
,(8.33333333%),而使用<article class="row">
<section class="col-xs-1">
<div class="box-row"></div>
</section>
<section class="col-xs-1">
<div class="box-row"></div>
</section>
</article>
<article class="row">
<section class="col-xs-1">
<div class="box-row"></div>
</section>
<section class="col-xs-1">
<div class="box-row"></div>
</section>
</article>
的情况并非如此。
def writedata(self, _arg1, _arg2, _arg3):
# self.sql_report is the fully qualified path of sqlite file
db = sqlite3.connect(self.sql_report)
c = db.cursor()
res = c.execute("Select id from State")
listRowId = []
for element in res.fetchall():
listRowId.append(element[0])
self.currentState = max(listRowId)
sql = "INSERT INTO Analysis (type, reason, Component_id, State_id) VALUES (?, ?, ifnull((SELECT id from `Component` WHERE name = ? LIMIT 1), 1), ?)"
# call to the write queue.
Report.strReference.writeToDb(sql, [(_arg1, _arg3, _arg2, self.currentState)])
File "/usr/lib/python2.6/threading.py", line 525, in __bootstrap_inner
self.run()
File "/usr/lib/python2.6/threading.py", line 477, in run
self.__target(*self.__args, **self.__kwargs)
File "/nameoffile", line 357, in nameofmethod
Report().writedata("test","text","analysis")
File "./nameofscript/Report.py", line 81, in writedata
ValueError: database parameter must be string or APSW Connection object