嗨,问题是我给输入绝对位置,但我发现绝对位置不能在输入标签中工作,任何人都可以知道吗?我只是想通过定位我的布局液体这就是为什么我在这里使用这是我的Html代码:
<div id="savevalue">
<input type="text" name="name" id="name" class="inpt" />
<input type="button" value="Submit" class="btn" />
</div>
Run Code Online (Sandbox Code Playgroud)
这是css代码:
.inpt{
background:#fff;
border:1px solid #ccc;
height:30px;
font-size:18px;
position:absolute;
left:0;
right:100px;
}
.btn{
height:30px;
background:#333;
border:1px solid #222;
font-size:18px;
color:#fff;
padding:0 15px;
position:absolute;
right:0;
}
Run Code Online (Sandbox Code Playgroud) 使用此 HTML,我无法弄清楚为什么文本显示在图像后面:
<div style="position: relative">
<img src="image_url_here" style="position:absolute; top: 10px; left: 10px;" />
This is some text, drawn on the page after the image, why is it drawn behind the image?
</div>
Run Code Online (Sandbox Code Playgroud)
?
在 Mac 和 PC 上的 Chrome 和 PC 上的 IE 中测试。
我正在尝试将文本放在页面上的图像中间.我想在页面上具有不同高度和宽度的其他图像上使用它.我有相对定位的图像和文本绝对定位,但底部:0似乎没有工作:
<div class="image">
<img src="http://lorempixel.com/300/300/">
<header class="text">
<h1>header</h1>
<a href="#">button</a>
</header>
</div>
Run Code Online (Sandbox Code Playgroud)
这是CSS:
.image {
display: inline-block;
position: relative;
}
.text {
position: absolute;
top: 0;
left: 0;
color: white;
text-align: center;
bottom: 0;
right: 0;
}
.text h1 {
text-transform: uppercase;
font-family: Helvetica, Arial;
font-size: 16px;
letter-spacing: .5px;
}
.text a {
font-size: 14px;
border: 1px solid white;
padding: 5px 30px;
color: white;
text-decoration: none;
}
Run Code Online (Sandbox Code Playgroud)
和小提琴的链接:http://jsfiddle.net/yg4Ar/
我有以下tcpdf代码:
<?php
require_once('config/lang/eng.php');
require_once('tcpdf.php');
// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {
//Page header
public function Header() {
}
// Page footer
public function Footer() {
}
}
// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Stimart');
$pdf->SetTitle('test');
$pdf->SetSubject('test');
$pdf->SetKeywords('test');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); …Run Code Online (Sandbox Code Playgroud) 根据与x 的绝对差值重新排列数组元素 ,即差值最小的元素排在前面,依此类推。就像我采用数组 [10, 5, 3, 9, 2, 3]和x = 7那么每个元素的绝对差应该是 =
7 - 10 = 3(abs)
7 - 5 = 2
7 - 3 = 4
7 - 9 = 2(abs)
7 - 2 = 5
7 - 3 = 4
Run Code Online (Sandbox Code Playgroud)
因此根据与 X 的差异,元素排列为[5,9,10,3,3,2]。
我已经通过下面的代码尝试过,但仍然失败:
7 - 10 = 3(abs)
7 - 5 = 2
7 - 3 = 4
7 - 9 = 2(abs)
7 - 2 = 5
7 - …Run Code Online (Sandbox Code Playgroud)我有两个<div>与position: absolute. 一个位于页面顶部,另一个位于页面底部。页面底部的元素低于最后一个元素(页脚)。我的问题是,即使我<div>在position: absolute流中并且应该从流中删除,我的页面<div>也会扩展以适应“溢出”的页面。如何让页面裁剪超出页脚的所有内容?
这就是我要说的:
body{
position: relative;
}
p{
width: 80%;
font-size: 50px;
margin: 0;
}
footer{
margin-top: 200px;
position: relative;
}
.bg_gradient.first{
position: absolute;
top: 0;
left: 0;
width: 1000px;
height: 1000px;
transform: translate(-400px, -400px);
background: radial-gradient(circle, rgba(254,73,70,1) 0%, rgba(254,73,70,0) 70%);
z-index: -1;
}
.bg_gradient.last{
position: absolute;
bottom: 0;
left: 0;
width: 1000px;
height: 1000px;
transform: translate(-400px, 400px);
background: radial-gradient(circle, rgba(254,73,70,1) 0%, rgba(254,73,70,0) 70%);
z-index: -1;
}Run Code Online (Sandbox Code Playgroud)
<body> …Run Code Online (Sandbox Code Playgroud)所以我有这个模板设计,目前绝对定位,但我试图让它在任何宽屏浏览器中居中.我已经尝试在容器的左侧和右侧设置宽度自动,但它仍然与左侧对齐.
CSS
.JosephSettin_png
{
position: absolute;
left:0px;
top:0px;
width:216px;
height:40px;
background: url("JosephSettin.png") no-repeat;
}
.home_png
{
position: absolute;
left:472px;
top:16px;
width:48px;
height:16px;
}
.discography_png
{
position: absolute;
left:528px;
top:16px;
width:80px;
height:24px;
}
.purchase_png
{
position: absolute;
left:608px;
top:16px;
width:88px;
height:24px;
}
.about_png
{
position: absolute;
left:696px;
top:16px;
width:48px;
height:24px;
}
.contact_png
{
position: absolute;
left:744px;
top:16px;
width:56px;
height:24px;
}
.main__pic_png
{
position: absolute;
left:0px;
top:56px;
width:264px;
height:264px;
background: url("main_pic.png") no-repeat;
}
.footer__lines_png
{
position: absolute;
left:0px;
top:512px;
width:800px;
height:24px;
background: …Run Code Online (Sandbox Code Playgroud) 我正在开发一个项目,我必须根据URL解析20个不同的HTML页面,我想从所有这些页面获取一些信息.页面具有不同的结构,所需信息位于每个站点的不同位置.
我想我可以试试Python lxml模块.由于信息可以在每个站点的不同位置找到,我很懒惰将20*X不同的注册表放在一起.表达式,我认为对这些元素使用绝对XPath是个好主意.通过这种方式,我可以简单地利用Chrome浏览器的复制XPath功能,并为我的解析器提供每个HTML元素的清晰路径,而且我不需要编写很多代码.
我找不到任何显示我如何在Python中使用绝对XPath引用HTML元素的示例.一些评论说,而不是绝对路径,最好使用相对,但不能真正解释原因.但同样,引用具有相对XPath的元素意味着一些编码再次工作.
只是为了使它更复杂这20个站点是unicode.
有没有办法在Python中引用具有绝对XPath的HTML元素并像这样获取其文本值?
/html/body/div[1]/table/tbody/tr[2]/td[2]/table/tbody/tr/td[2]/div/table/tbody/tr[3]/td[2]/table/tbody/tr[2]/td/table/tbody/tr/td[2]/font/b
Run Code Online (Sandbox Code Playgroud)
...它将返回HTML元素的文本值.
到目前为止,我得到了以下代码,它适用于相对XPath,但当我使用绝对时,它给我下面的错误.
import urllib2
from lxml import html
from bs4 import UnicodeDammit
response = urllib2.urlopen('http://oneofthesites.com')
content = response.read()
doc = UnicodeDammit(content, is_html=True)
parser = html.HTMLParser(encoding=doc.original_encoding)
root = html.document_fromstring(content, parser=parser)
data = root.find('/html/body/div[1]/table/tbody/tr[2]/td[2]/table/tbody/tr/td[2]/div/table/tbody/tr[1]/td[2]/b').text_content()
print(data)
Run Code Online (Sandbox Code Playgroud)
而错误是:
SyntaxError: cannot use absolute path on element
Run Code Online (Sandbox Code Playgroud)
也许我的基本概念是错误的,所以关于如何处理这些页面的任何其他想法都是受欢迎的!
感谢您的帮助,g0m3z
我正在尝试创建一个1页的滚动布局:http: //codepen.io/TimRos/pen/vOXVQM
每个"页面"都是这样构建的:
section {
display: flex;
min-height: 100vh;
flex-direction: column;
}
Run Code Online (Sandbox Code Playgroud)
现在,我希望能够通过单击位于该部分底部的锚点来滚动到不同的部分.这在#home部分工作正常:
<a data-scroll href="#gallery"><span class="arrow">∨</span></a>
Run Code Online (Sandbox Code Playgroud)
CSS:
.arrow {
position: absolute;
bottom: 0;
width: 60px;
font-size: 3em;
color: #e3e3e3;
background: #3f3f3f;
}
Run Code Online (Sandbox Code Playgroud)
当我在每个部分放置完全相同的锚点时,只要我给它一个位置:绝对; 和底部:0; 归因于它位于#home部分的底部,但我希望它坚持其父容器的底部.
页脚也存在同样的问题,绝对定位会粘在第一部分的底部,而不是它的父部分.
出了什么问题?
第二大绝对值形式数组
输入:数组(13,-12,8,2,5)
预期答案:12
这是我的代码
<?php
function print2largest($arr, $arr_size)
{
if ($arr_size < 2)
{
echo(" Invalid Input ");
return;
}
$first = $second = PHP_INT_MIN;
for ($i = 0; $i < $arr_size ; $i++)
{
if ($arr[$i] > $first)
{
$second = $first;
$first = $arr[$i];
}
else if ($arr[$i] > $second &&
$arr[$i] != $first)
$second = $arr[$i];
}
if ($second == PHP_INT_MIN)
echo("There is no second largest element\n");
else
echo("The second largest element is " . $second . …Run Code Online (Sandbox Code Playgroud)