我总是听说CSS中的边距会在彼此相邻时崩溃,因此设置两个元素以使其全部为40px只会导致它们之间的40px.
这是一种渲染CSS的旧方法,因为它不再以这种方式工作了吗?
这是HTML和CSS.我似乎无法让边缘崩溃:
<div id="header">
<div id="mainNav" class="navBar">
<a id="homeLink" class="navBarLinks">Home</a>
<a id="aboutLink" class="navBarLinks">About</a>
<a id="articlesLink" class="navBarLinks">Articles</a>
<a id="portfolioLink" class="navBarLinks">Portfolio</a>
<a id="contactLink" class="navBarLinks">Contact</a>
<a id="rssLink" class="navBarLinks">RSS</a>
</div>
<div class="infoBar"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
#header { width: 100% }
.navBar {
width: 100%;
height: 24px;
background-color: #1a1a1a;
border: 0px solid #404040
}
#mainNav { border-bottom-width: 2px }
.navBarLinks {
display: block; float: left;
height: 11px;
margin: 0 30px;
background: url(/images/STORMINKsprite.png) no-repeat;
text-indent: -9999px
}
Run Code Online (Sandbox Code Playgroud)
感谢您的建议!
我想通过XAML更改WPF文本框的左边距:
这段代码显然不起作用:
<TextBox Margin.Left ="0"/>
Run Code Online (Sandbox Code Playgroud)
什么是正确的代码,这里的任何人都知道吗?
此致,MadSeb
所以,我正在以编程方式添加标签,我需要将上边距稍微改为值8.我不能以明显的方式做到这一点,所以我的想法出了什么问题?
Dim LabelAdapter As New Label
LabelAdapter.text = "Adapter"
LabelAdapter.Margin.Top = 8
Run Code Online (Sandbox Code Playgroud)
这给了我错误"表达式是一个值,因此不能成为赋值的目标".
大家好我已经使用以下代码创建了布局
android:layout_height="wrap_content"></TextView>
<EditText android:layout_height="wrap_content"
android:padding="12dip" android:layout_width="wrap_content" android:text="EditText" android:id="@+id/editText1"></EditText>
</TableRow>
</TableLayout>
<TableRow android:layout_width="match_parent" android:id="@+id/tableRow2" android:layout_height="wrap_content">
<TextView android:text="TextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView2"></TextView>
<EditText android:text="EditText" android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText>
</TableRow>
<TableRow android:layout_width="match_parent" android:id="@+id/tableRow3" android:layout_height="wrap_content">
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</TableRow>
Run Code Online (Sandbox Code Playgroud)
但现在我想设置margin.how我可以使用XML吗?
我必须在LinearLayout上添加多个按钮.但我想把这些按钮分开5px.我找不到设置按钮边距的方法.任何的想法?
我正在尝试在css中为页面设计一个简单的标题.我计划将两个div叠加在一起.顶部有一个标签,底部是一个简单的单个图像div.但是在渲染时我发现额外的5px被添加到这两个div的高度.所以我无法将底部正好放在另一个底部.
自动存在5px的底部保证金.我尝试了负边距,将全局边距和填充重置为零.仍然没有用.
继承人的代码.
<div class ="main_nav">
<div class="first_tab">
<img src ="images/startup/tab1_brown.png" height="25" width="90" alt="Temp" />
</div>
<div class = "ind_tab">
<img src ="images/startup/tab1_orange.png" height="25" width="90" alt="Temp"/>
</div>
<div class = "ind_tab">
<img src ="images/startup/tab1_brown.png" height="25" width="90" alt="Temp" />
</div>
</div>
<div class="lock">
<img src ="images/startup/divbg_new.png" alt="Temp" />
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
*{ margin:0; padding:0; }
ul.master_navigation
{
font-size: 125%;
font-weight: bold;
text-align: center;
list-style: none;
margin: 0.5em 0;
padding: 0;
}
ul.master_navigation li
{
display: inline-block;
padding: 0 1%;
}
a
{ …Run Code Online (Sandbox Code Playgroud) 我在xml中有一个radiogroup,按钮是以编程方式生成的.如何以编程方式在按钮之间添加间距.
我认为这是类似的东西,LayoutParams但我的对象没有明显setPadding或setMargins方法.
这就是我的尝试
RadioButton currentButton = new RadioButton(context);
currentButton.setText(item.getLabel());
currentButton.setTextColor(Color.BLACK);
//add padding between buttons
LayoutParams params = new LayoutParams(context, null);
params. ... ??????
currentButton.setLayoutParams(params);
Run Code Online (Sandbox Code Playgroud) 我们假设我们有以下代码:
<div style="margin-bottom:100px;">test</div>
<div style="margin-top:100px;">test</div>
Run Code Online (Sandbox Code Playgroud)
我注意到有时它会在元素之间创建100px的边距,有时它会产生200px(当我们使用某些我不熟悉的设置时).我在规范中找不到任何相关信息.这取决于什么?
如果我们有h1,并p在一个空白文档,然后的利润率h1将与的保证金组合p.他们不会加起来.将使用较大者.
我正在创建包含a的动态视图LinearLayout并将它们添加到外部LinearLayout.我想在创建的视图周围设置边距,但layout_margin忽略XML文件中的边距.如果我在代码中设置参数,它可以工作,但我想在布局XML中指定边距.
设置XML布局中的边距将被忽略:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:orientation="vertical" >
...
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在创建时设置边距是值得尊重的:
LinearLayout productView = (LinearLayout) getLayoutInflater().inflate(R.layout.product_preview, null);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
params.setMargins(50, 50, 50, 50);
productView.setLayoutParams(params);
Run Code Online (Sandbox Code Playgroud)
这是外部布局.视图已添加到dealer_activity_product_list.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/dealer_activity_dealer_image"
android:layout_width="match_parent"
android:layout_height="150dp"
android:contentDescription="@string/dealer_activity_dealer_image_desc" />
<TextView
android:id="@+id/dealer_activity_dealer_address"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/dealer_activity_product_list1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" />
<LinearLayout
android:id="@+id/dealer_activity_product_list2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的Flutter布局有问题.
我有一个简单的容器,右边和左边的边距为20.0.在这个容器内,我有另一个容器.
但是这个容器只适合左侧的父容器.我不知道为什么会这样.
这是我的代码:
@override
Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Colors.white,
body: new Container(
margin: new EdgeInsets.symmetric(horizontal: 20.0),
child: new Container(
)
),
);
}
Run Code Online (Sandbox Code Playgroud)