我找到了一个技巧来防止子元素拉伸其 flexbox 父元素。
为此,我使用:
.magic {
background: yellow;
display: flex;
flex-direction: column;
width: 300px;
}
.magic > div {
flex: 1;
height: 0; // this makes the trick
overflow: auto;
}
Run Code Online (Sandbox Code Playgroud)
http://codepen.io/FezVrasta/pen/bdgyNj
如您所见,左列有滚动条,而不是拉伸整个 flexbox。
但是这个东西在 Firefox 上不起作用(可能在 IE 上,我无法测试它)。
你们知道如何让它跨浏览器工作吗?
我写了一个简单的语法:
operations :
/* empty */
| operations operation ';'
| operations operation_id ';'
;
operation :
NUM operator NUM
{
printf("%d\n%d\n",$1, $3);
}
;
operation_id :
WORD operator WORD
{
printf("%s\n%s\n%s\n",$1, $3, $<string>2);
}
;
operator :
'+' | '-' | '*' | '/'
{
$<string>$ = strdup(yytext);
}
;
Run Code Online (Sandbox Code Playgroud)
如您所见,我定义了operator可以识别4个符号之一的。现在,我要在中打印该符号operation_id。问题是,逻辑operator仅适用于替代中的最后一个符号。所以如果我写a / b; 它显示ab /,这很酷。但是对于其他操作,例如。a + b; 它打印aba。我究竟做错了什么?
*我在示例输出中省略了换行符号。
我有两个弹性项目; #left应该是640像素宽,#right应该只需填写容器的其余部分,但如果#right中有很长的话,它忽略了#left的flex-basis:640px,基本上把它变成一些奇怪%的宽度.如果我删除了#right内容,一切都按预期工作.
我有这样的代码:
<ul class="tiles">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
和css:
ul.tiles{
width: 220px;
height: 200px;
list-style-type: none;
background: #cecece;
padding: 0;
}
li{
display: inline-block;
width: 50px;
height: 50px;
background: #8ac249;
text-align: center;
line-height: 50px;
margin: 5px;
float: left;
}
Run Code Online (Sandbox Code Playgroud)
看起来如此:
将它更改为这样的模型是真实的(没有弹性框):
如何?
我已经构建了一个组件,它绘制了一个给定大小的彩色圆圈.在圆圈的中心显示一个数字或字符:
此外,应在圆圈边框的右下角显示绿色圆圈.
ReactNative-StyleSheet如下所示:
circle: {
width: 100, // this should be a "props"-value in future
height: 100, // this should be a "props"-value in future
borderRadius: 100/2,
backgroundColor: 'red',
alignItems: 'center',
justifyContent: 'center',
},
circleCaption: {
fontSize: 70,
},
symbol: {
width: 16,
height: 16,
borderRadius: 16/2,
backgroundColor: 'green',
position: 'absolute',
right: 8,
bottom: 8,
},
Run Code Online (Sandbox Code Playgroud)
并以这种方式将形状放入视图中:
<View style={s.circle}>
<Text style={s.circleCaption}>A</Text>
<View style={s.symbol} />
</View>
Run Code Online (Sandbox Code Playgroud)
有了这些因素(右:8,底部:8),绿色圆圈直接放在圆圈的右下角.
如何使用圆形尺寸动态放置它?如何计算底部/右侧值?
此外,如果在红色圆圈的中心绘制的字符,数字或符号变得太大而不适合圆圈,则绿色圆圈离开圆圈并失去其固定位置.有什么想法吗?不幸的是,ReactNative没有提供Z-Index.
我正在寻找为 C 中的某些字符串制作正则表达式。
这是我到目前为止:
C 中的字符串由双引号 (") 分隔,因此正则表达式必须用 \" \" 括起来。
该字符串可能不包含换行符,所以我需要做 [^\n] (我认为)。
当且仅当它们被转义时,字符串也可能包含双引号或反斜杠字符。因此 [\\ \"] (我再次认为)。
除此之外,其他任何事情都会发生。
非常感谢任何帮助我对如何开始编写这个正则表达式有点迷茫。
我有以下标记:
.container {
display: flex;
width: 500px;
}
.col1 {
background: red;
height: 100%;
width: 50px;
}
.col2 {
background: blue;
flex: 1;
height: 200px;
}Run Code Online (Sandbox Code Playgroud)
<div class="container">
<div class="col1"></div>
<div class="col2"></div>
</div>Run Code Online (Sandbox Code Playgroud)
我希望它看起来像这样:
但是当在浏览器中呈现并检查时,高度.col1为0px。我希望它是200px因为.col2将容器的高度拉伸到那个大小。我究竟做错了什么?
我使用C代码中的Code :: Blocks和C代码,并且有一些错误.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define SQRT(num) \
((num>0) ?\
(sqrt(num)): \
(printf("the number is negative")))
int main() {
printf("The file %s is executeD \n", _FILE_);
printf("the sqrt of number %d is %f \n",8,SQRT(8));
printf("the sqrt of number %d is %f \n",9,SQRT(9));
printf("the sqrt of number %d is %f \n",-9,SQRT(-9));
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我的页面布局由以下内容组成:
我希望 flex 增长内容能够容纳一个方形 div,其尺寸等于CONTENT 元素的高度。
我无法实现此约束,因为对正方形使用 width = 100vh 并不能计算内容高度的 100%!
您可以在这里查看我到目前为止所拥有的内容:http ://jsfiddle.net/tgs93kLr/
<div class="body">
<div class="header">header</div>
<div class="content">
<div class="square"></div>
</div>
<div class="footer">footer</div>
</div>
Run Code Online (Sandbox Code Playgroud)
和
.body {
height: 250px;
display: flex;
flex-flow: column;
background: red;
}
.header {
height: 100px;
background: blue;
}
.footer {
height: 100px;
background: green;
}
.content {
flex-grow: 1;
background: yellow;
}
.square {
background: black;
width: 100vh;
height: 100vh;
}
Run Code Online (Sandbox Code Playgroud)
您对如何实现此目标有任何想法吗?注意:对于内容宽度<高度的情况,我已经有了一个解决方案