我有一个非常奇怪的问题...在每个浏览器和移动版本中我遇到这种行为:
怎么能避免这个问题?当我第一次听到视口高度时,我很兴奋,我认为我可以将它用于固定高度块而不是使用javascript,但现在我认为唯一的方法是实际上javascript与一些resize事件......
任何人都可以帮我/建议一个CSS解决方案吗?
简单的测试代码:
/* maybe i can track the issue whe it occours... */
$(function(){
var resized = -1;
$(window).resize(function(){
$('#currenth').val( $('.vhbox').eq(1).height() );
if (++resized) $('#currenth').css('background:#00c');
})
.resize();
})Run Code Online (Sandbox Code Playgroud)
*{ margin:0; padding:0; }
/*
this is the box which should keep constant the height...
min-height to allow content to be taller than viewport if too much text
*/
.vhbox{
min-height:100vh;
position:relative;
}
.vhbox .t{
display:table;
position:relative;
width:100%;
height:100vh;
}
.vhbox .c{ …Run Code Online (Sandbox Code Playgroud)版本:0.6.0 beta 3
我试着以各种方式让dompdf设置页面的边距.我有一个很长的页面,有很多文字,分为章节......
我的css是这样的:
#wrapper{
padding:8px;
}
/* other styles... */
@page{margin: 0.2in 0.5in 0.2in 0.5in;}
Run Code Online (Sandbox Code Playgroud)
当PHP是
<?php
ob_start(); // begin collecting output
include 'makemypdf.php'; // this page output the html
$html = ob_get_clean(); // retrieve output from makemypdf.php and stop buffering
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf", array("Attachment" => false));
?>
Run Code Online (Sandbox Code Playgroud)
但我得到的是一个没有利润的页面!只应用#wrapper的填充...并且它们仅在整个PDF的开头和结尾应用...
我做错了什么?
PS - 似乎只应用了底部保证金...但我不确定......
PPS - 我试过这个css:body {margin-top:40px; } html {margin-top:40px; } @page {margin-top:40px; }
在chrome中 - 我不知道在其他浏览器中(我不关心这个时间,但答案对他们中的任何一个都有效) - 如果你没有设置整个日期(例如,错过了小时和分钟 - : - ),输入值为空...
我怎么知道插入了什么非空值?或者chrome等待设置输入的值,直到所有字段全部设置完毕?
我认为一个我不喜欢的残酷方法:设置一个默认值(例如今天或1970年1月1日),然后chrome必须设置输入的值,然后所有的值都可以,即使用户不喜欢t手动设置日期.
<input id="INPUT" type="datetime-local" name="ciccio">
Run Code Online (Sandbox Code Playgroud)
渲染类似于
**-**-**** --:--
Run Code Online (Sandbox Code Playgroud)
其中*是日,月,年的字段.
如果你输入:
12-03-2013 --:--
Run Code Online (Sandbox Code Playgroud)
并通过javascript请求INPUT的值
console.log($('#INPUT').val());
//the result is "" (nothing).
Run Code Online (Sandbox Code Playgroud)
但插入了一些东西
我试图弄清楚这个简单而复杂的任务是否有解决方案.
假设我们有这些变量:
var dom1 = $('.selector1');
var dom2 = $('.selector2');
Run Code Online (Sandbox Code Playgroud)
现在我想申请一个dom1和dom2的监听器.是否有一个不同的,直接的,更可靠的解决方案,而不是逐个应用这个功能?
dom1.click(function(){
//a lot of stuff
}
dom2.click(function(){
//the same lot of stuff
}
//or
$([dom1,dom2]).each(function(){
this.click(function(){
//the same lot of stuff
});
}
Run Code Online (Sandbox Code Playgroud)
我知道这不是一个有效的解决方案,但我正在搜索这样的东西:
//NOT WORKING, NON-SENSE, I KNOW
$([dom1,dom2]).click(function(){
//the same lot of stuff
}
Run Code Online (Sandbox Code Playgroud)
先感谢您.
我有麻烦试图动态地添加图片,因为lightbox2(由LOKESH达喀尔)的存在HTML编码图像文件加载后初始化,并没有在第一时间之后再解析文档.
如果我尝试使用javascript添加新图像(例如将它们添加到正文中),则不会将它们添加到lighbox组中.
官方网站上的文档似乎没有描述任何脚本方法
有经验的人可以帮助我吗?使用jquery的解决方案真的很受欢迎,但我也可以处理好vanilla js.
代码示例:
HTML
<body>
<div id="container">
<a href="images/image-2.jpg" data-lightbox="roadtrip">Image #2</a>
<a href="images/image-3.jpg" data-lightbox="roadtrip">Image #3</a>
<a href="images/image-4.jpg" data-lightbox="roadtrip">Image #4</a>
</div>
<!-- where 'Image #X' = <img src="images/thumb/image-X.jpg>" -->
<div id="loadmore">load more images</div>
<script src="path/to/lightbox.js"></script>
<script>
/* see below for the script */
</script>
</body>
Run Code Online (Sandbox Code Playgroud)
JavaScript的
$(function(){
$('#loadmore').click(function(){
//ajax request for more images.
//load them with all the needed properties...
//then put them into the container:
var IMG = $('<a href="images/image-10.jpg" …Run Code Online (Sandbox Code Playgroud) 我用 jquery 做了一些带有 name 属性的代码!!!一个 DIV !!!并以某种方式使用它。
如果一方面我在我拥有的每个浏览器(firefox,chrome,即 9/8/7,safari,opera,android ......所有与上次更新)中都尝试过这段代码并且它运行良好,另一方面我看到了- 用谷歌搜索 - "name" 只被认为是form , input , textarea , a和其他类似的。
我真的可以像以前一样使用它吗?在我想要的每个 html 标签中?或者我会在地狱里永远燃烧?
先感谢您
看到你的答案,我决定以其他方式存储数据(比如添加类并即使使用 jquery 检索它们的名称)。