我想通过仅使用ui.xml文件使用所述面板进行绝对布局,但是不清楚这是否可行,因为文档集中于代码并完全忽略布局语言.我假设,因为教程没有提到这一点,这是不可能的,但我想肯定.
这在模拟器上工作正常但在设备上没有,因为我已经将高度硬编码为365.任何人都可以在这方面帮助我吗?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost android:id="@+id/tab_host"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TabWidget android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@android:id/tabs"
android:layout_gravity="bottom"/>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:id="@+id/first_tab"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="365px">
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/widget31"
android:layout_width="fill_parent"
android:layout_height="49px"
android:layout_x="0px"
android:layout_y="0px"
android:background="#39000000"
android:layout_alignParentBottom="true">
</ImageView>
<ImageButton
android:id="@+id/btnFB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/fb"
android:background="#00000000"
android:layout_alignRight="@+id/widget31"
android:layout_alignParentBottom="true">
</ImageButton>
<TextView
android:id="@+id/myTextView1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Share"
android:textColor="#111111"
android:textSize="14pt"
android:paddingBottom="5px"
android:layout_alignLeft="@+id/widget31"
android:layout_alignParentBottom="true"/>
<ImageButton
android:id="@+id/btnTwitter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/twitter"
android:visibility="invisible"
android:background="#00000000"
android:layout_alignRight="@+id/widget31"
android:layout_alignParentBottom="true">
</ImageButton>
<!-- Replace TextView with your layout content for this tab …Run Code Online (Sandbox Code Playgroud) 我有一个<div>定位的position:fixed.当窗口水平太小而不适合div时,不会出现滚动条,div的右侧只是被切掉了.
如果我更改为position:absolute,则滚动条显示为正常.
是否有任何方法可以让浏览器识别div的大小和滚动的需要,同时仍然使用position:fixed?
注意:在固定div之前还有另一个具有默认位置的div.
我把头发拉过来.我有一个网页,我希望在左侧有一个固定的位置div(鹦鹉和翻译),当它向下滚动时跟随页面. http://www.cartoonizemypet.com/new/help/
我设法跟随这个问题http://jqueryfordesigners.com/fixed-floating-elements/并获得我认为完美的效果!然后我尝试在手机上查看它....一旦我放大了爆破的div移动了文本!:(您可以通过缩小浏览器窗口并向右滚动来查看常规浏览器的影响.
有没有人知道防止鹦鹉水平移动的方法?我一直在寻找解决方案的高低,但它似乎开始变得不可能了.
这是相关的CSS
#content {
padding-top:20px;
padding-bottom:713px; /* Height of the footer element */
width:888px;
margin-left:auto;
margin-right:auto;
position:relative;
}
#help-col1 {
left:0;
width:218px;
position:absolute;
height:500px;
}
#parrot-box {
position:absolute;
top:0;
margin-top: 20px;
}
#parrot-box.fixed {
position:fixed;
top:0;
}
#help-col2 {
width:634px;
float:right;
}
Run Code Online (Sandbox Code Playgroud)
请随意查看页面源代码(http://www.cartoonizemypet.com/new/help/)以查看SCRIPT和HTML.任何帮助将非常感激.
考虑下面的网页.它<img>的位置绝对与其父级相关,当我在Safari或Firefox上加载此页面时,会<img>出现在右上方,如预期的那样(请参阅第一张图片).但是,当边框从中移除时<div>,例如,通过设置border-width: 0,<img>位置本身绝对相对于<p>标签,它的兄弟!见图2.为什么是这样?边界应该有什么不同?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
body {
margin: 0;
}
div {
position: relative;
left: 0;
top: 0;
border: 1px solid red;
}
img {
position: absolute;
right: 0;
top: 0;
}
p {
margin: 20px;
}
</style>
</head>
<body>
<div>
<img src="content/en/flag.png" />
<p>This is a test</p>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

请在这里找到我的设计:http://jsfiddle.net/2JGQa/
我想修复左栏(包括testlab_fr,1er mail,...,10eme mail),就像我的标题一样,我怎么能这样做?
我看到了词缀,但我不知道如何使用它.
<div class="row">
<div class="col-sm-4">
<div class="row">
<ul class="list-group">
<li class="list-group-item">
<span class="badge">175</span>
testlab_fr
</li> </ul>
</div>
<div class="row">
<div class="list-group">
<a href="http://localhost/mailbox/testlab_fr,26860-html" class="link_mail list-group-item active">
<h4 class="list-group-item-heading">1er mail</h4>
<p class="list-group-item-text">il y a 1 hours</p>
</a>
<a href="http://localhost/mailbox/testlab_fr,25877-html" class="link_mail list-group-item">
<h4 class="list-group-item-heading">10ème mail</h4>
<p class="list-group-item-text">il y a 2 heures</p>
</a> </div>
</div>
</div><!-- /.col-sm-4 -->
Run Code Online (Sandbox Code Playgroud) 由于某种原因,它将按钮放在div的外面,就在右上角的上方.好像就在div的右上角上方就像右下角一样.
例如,如果我添加底部10px,它将从div开始并将其向上移动10px.同样的事情发生在右边
CSS:
#newSignupContent {
display: block;
position: relative;
width: 400px;
height: 250px;
margin: auto auto;
}
#newSignupContent label {
display: inline-block;
float: left;
clear: left;
width: 40%;
padding-right: 10px;
text-align: right;
color: white;
font-family:calibri, Times, serif;
font-size: 22px;
}
#newSignupContent input {
display: inline-block;
width: 50%;
float: left;
padding: 5px 10px 5px 0px;
}
#newSignupContent #newSignupSubmit {
position: absolute;
bottom: 0;
right: 0;
width: 80px;
height: 40px;
padding: 5px 10px 5px 10px;
}
Run Code Online (Sandbox Code Playgroud)
形成:
<div id="newSignupContent">
<form action="/webroot/NewUserSignUpProcess" method="post"> …Run Code Online (Sandbox Code Playgroud) 我遇到了固定定位,css转换容器和Safari的麻烦.当我在模态中单击项目时,我正在尝试显示下拉列表.模态有一个css transform.为了确保下拉列表始终显示在模态上,我将其定位为固定(我使用JS 计算left和top值).
它在Chrome,Firefox和Opera中的效果与预期相同,但Safari显示出一种奇怪的行为.根据W3C:
对于变换,除了none之外的任何计算值都会导致创建堆叠上下文和包含块.该对象充当固定定位后代的包含块.
因此,CSS转换容器中的固定元素应相对于此容器而不是视口定位.但似乎Safari并不像这样.看这个例子:
$(document).ready(function() {
$(".show-liste").click(function() {
$(".liste").show();
});
});Run Code Online (Sandbox Code Playgroud)
.modale {
height: 50px;
overflow-y: scroll;
transform: translate(100px);
}
ul {
position: fixed;
left: 0px;
top: 0px;
}
/* --- Purely style related stuff ---- */
body {
font-size: 80%;
}
.modale {
position: absolute;
top: 50px;
padding: 60px;
background-color: white;
border: 1px solid #ccc;
box-shadow: 2px 2px 2px #ddd;
}
button {
width: 200px;
}
ul {
list-style-type: none; …Run Code Online (Sandbox Code Playgroud)我正在尝试修复position元素,并采用父div的完整宽度。这是我的html:
<div class="col-md-3">
<div class="player-avatar-card">
<div class="card-body">
<div class="avatar-image">
<img src="/imagecache/small/{{ $player->image_filename }}" alt="Profile Image" class="rounded-circle">
<img class="flag rounded-circle" src="/icons/flags-round/{{ $player->nationality }}.svg"></h3>
</div>
<h5>{{ $player->first_name }} {{ $player->last_name }}</h5>
<p>{{ $player->nationality }}, {{ $player->age }} years</p>
<div class="social-buttons">
<div class="col-12">
<a class="btn btn-info btn-lg" href="#" role="button">
<i class="ion-plus-round"></i> follow</a>
</div>
<div class="col-12">
<a class="btn btn-info btn-outline-info" href="#" role="button">
<i class="ion-android-share-alt"></i> share</a>
</div>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我player-avatar-card在滚动到元素时将位置定位类提供给:
const avatarCard = document.querySelector('.player-avatar-card');
const fixClassAvatar = 'is-fixed-avatar';
function stickyScroll() { …Run Code Online (Sandbox Code Playgroud) 我知道任何具有position:absolute的元素都将相对于最近的祖先定位,其位置属性如绝对或相对.这在例如此处的各种答案中提到.也在这里的w3schools网站上......
位置为绝对的元素; 相对于最近定位的祖先定位(而不是相对于视口定位,如固定).
但是,插入静态元素似乎会破坏此规则并移动绝对元素.我想知道为什么会这样.请参阅下面的代码段.
如果静态元素被追加到绝对值,则后续元素将按预期显示(根据最近的位置祖先规则).
div.relative {
position: relative;
width: 440px;
height: 600px;
border: 3px solid #73AD21;
}
div.static {
position: static;
width: 200px;
height: 100px;
border: 3px solid #73ADff;
}
div.absolute {
position: absolute;
width: 200px;
height: 100px;
border: 3px solid #73AD21;
}
div.absolute2 {
left:210px;
position: absolute;
width: 200px;
height: 100px;
border: 3px solid #ffAD21;
}Run Code Online (Sandbox Code Playgroud)
<div class="relative">This div element has position: relative;
<div class="static">This div element has …Run Code Online (Sandbox Code Playgroud)css-position ×10
css ×6
html ×3
jquery ×2
android ×1
bootstrap-4 ×1
css3 ×1
fixed ×1
gwt ×1
javascript ×1
layout ×1
transform ×1