我正在寻找一种解决方案,让孩子div
适应它的父母width
.
我在这里看到的大多数解决方案都不是跨浏览器兼容的(例如display: table-cell;
IE中不支持<=8
).
我有一个网站,其布局已在图表中显示.所述主体包括一个main container
,该方法包括header
,parent div
和footer
.所述parent div
进一步包含若干child div
如图所示.
问题是所有的高度child div
是有限的.但parent div
除了儿童div之外什么都没有.所有子div都可见,但父div的高度显示为零.我也没有通过给出一些预先指定的值来修正父div的高度,因为如果将来孩子的数量增加可能会导致错误.
由于父div的大小为零而导致的问题是我的页脚div正在上升并与父div的内容冲突.这可以通过给出合适的margin-top来解决,但这不是我正在寻找的解决方案.
任何人都可以建议我某种方式,以便父div的高度根据存在的子div的高度自动改变.
如果我不清楚我的疑问,请发表评论!
有没有办法在mySQL的子查询中指定父查询字段?
例如:
我用PHP编写了一个基本的公告板类型程序.
在数据库中,每个帖子包含:id(PK)和parent_id(父帖子的id).如果帖子本身是父级,则其parent_id设置为0.
我正在尝试编写一个mySQL查询,它将查找每个父帖子以及父母拥有的子节点数.
$query = "SELECT id, (
SELECT COUNT(1)
FROM post_table
WHERE parent_id = id
) as num_children
FROM post_table
WHERE parent_id = 0";
Run Code Online (Sandbox Code Playgroud)
棘手的部分是第一个id不知道它应该引用子查询之外的第二个id.我知道我可以做SELECT id AS id_tmp然后在子查询中引用它,但是如果我还想返回id并保持"id"作为列名,那么我必须做一个返回的查询我有2列相同的数据(这对我来说似乎很乱)
$query = "SELECT id, id AS id_tmp,
(SELECT COUNT(1)
FROM post_table
WHERE parent_id = id_tmp) as num_children
FROM post_table
WHERE parent_id = 0";
Run Code Online (Sandbox Code Playgroud)
凌乱的方式很好,但我觉得有机会在这里学到一些东西,所以我想我会发布这个问题.
我有以下结构:
src/
modules/
module1/
js/
main.js
scss/
main.scss
index.html
module2/
js/
main.js
scss/
main.scss
index.html
Run Code Online (Sandbox Code Playgroud)
我想运行一个繁琐的任务来将这些复制到以下结构:
dev/
js/
module1.js
module2.js
css/
module1.css
module2.css
module1.html
module2.html
Run Code Online (Sandbox Code Playgroud)
有没有办法用现有的grunt插件做到这一点?如果没有,我怎么能实现这个目标?
如何将childNode附加到javascript中的特定位置?
我想将一个childNode添加到div中的第3个位置.它背后还有其他节点需要向后移动(3变为4等)
如何将孩子的值传递回父表单?我有一个字符串,我想传递给父母.
我使用以下方式启动了孩子
FormOptions formOptions = new FormOptions();
formOptions.ShowDialog();
Run Code Online (Sandbox Code Playgroud) 是否有任何方法可以让python + selenium找到父元素,兄弟元素或子元素
driver.find_element_parent?
或
driver.find_element_next?
或
driver.find_element_previous
?
例如:
<tr>
<td>
<select>
<option value=0, selected='selected'> </option>
<option value=1, > </option>
<option value=2,> </option>
</select>
</td>
<td> 'abcd'
<input name='A'> </input>
<td>
<tr>
Run Code Online (Sandbox Code Playgroud)
我尝试过如下,但失败了:
input_el=driver.find_element_by_name('A')
td_p_input=find_element_by_xpath('ancestor::input')
Run Code Online (Sandbox Code Playgroud)
如何获取input元素的父元素,最后选择选项?
量角器什么是选择子元素的最佳方式?假设我们有以下布局......
<div id='parent_1'>
<div class='red'>Red</div>
<div class='blue'>Blue</div>
</div>
<div id='parent_2'>
<div class='red'>Red</div>
<div class='blue'>Blue</div>
</div>
Run Code Online (Sandbox Code Playgroud)
使用jQuery,我们会做这样的事情.
var p1 = $('#parent_1');
var p1_red = $('.red', p1); //or p1.find('.red');
var p1_blue = $('.blue', p1); //or p1.find('.blue');
Run Code Online (Sandbox Code Playgroud)
但是使用Protractor,首先获得父元素是否有意义?因为这样做var p1 = element('#parent_1');
实际上不会检索/搜索对象,直到getText()
调用它为止.
这样做..
场景1
expect(p1.element('.red')).toBe('red');
expect(p1.element('.blue')).toBe('blue');
Run Code Online (Sandbox Code Playgroud)
要么
情景2
expect(element('#parent_1').element('.red')).toBe('red');
expect(element('#parent_1').element('.blue')).toBe('blue');
Run Code Online (Sandbox Code Playgroud)
要么
场景3
expect(element('#parent_1 > .red')).toBe('red');
expect(element('#parent_1 > .blue')).toBe('blue');
Run Code Online (Sandbox Code Playgroud)
一种方法相对于另一种方法有什么好处吗?
这就是我正在做的事情,但我不知道将父母与cssSelector分开是否有任何好处:
function getChild(cssSelector, parentElement){
return parentElement.$(cssSelector);
}
var parent = $('#parent_1');
var child_red = getChild('.red', parent);
var child_blue = getChild('.blue', parent); …
Run Code Online (Sandbox Code Playgroud) 我有一个关于从Child Entites引用ParentEntities的问题如果我有这样的事情:
Parent.java:
@Entity(name ="Parent")
public class Parent {
@Id
@Generate.....
@Column
private int id;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parent")
private Set<Child> children;
simple ... getter and setter ...
}
Run Code Online (Sandbox Code Playgroud)
而Child.java:
@Entity(name ="Child")
public class Child{
@Id
@Generate....
@Column
private int id;
@ManyToOne
private Parent parent;
... simple getter an setter
}
Run Code Online (Sandbox Code Playgroud)
将创建以下表:
Parent:
int id
Child:
int id
int parent_id (foreign key: parent.id)
Run Code Online (Sandbox Code Playgroud)
好吧,到目前为止,everthings很好.但是当谈到从Java使用这个参考时,我想,你可以做这样的事情.
@Transactional
public void test() {
Parent parent = new Parent();
Child …
Run Code Online (Sandbox Code Playgroud) 我有FragmentActivity
这个布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menulabel"
android:textSize="24sp" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text"
android:layout_below="@+id/textView1"
android:hint="@string/search_title_hint" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/spinnersearch"
android:layout_below="@+id/editText1" />
<LinearLayout
android:id="@+id/layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView2" >
<Spinner
android:id="@+id/spinner_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:prompt="@string/spinnersearch" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/reset_search" />
</LinearLayout>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buttonnewcat"
android:layout_below="@+id/layout1" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buttondelcat"
android:layout_below="@+id/button2" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buttoneditcat"
android:layout_below="@+id/button3" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buttonnewtext" …
Run Code Online (Sandbox Code Playgroud)