小编ben*_*oît的帖子

CSS媒体查询和JavaScript窗口宽度不匹配

对于响应式模板,我在CSS中有一个媒体查询:

@media screen and (max-width: 960px) {
 body{
 /*  something */
 background:red;
 }
}
Run Code Online (Sandbox Code Playgroud)

并且,我在调整大小到日志宽度时创建了一个jQuery函数:

$(window).resize(function() {
 console.log($(window).width());
 console.log($(document).width()); /* same result */
 /* something for my js navigation */
}
Run Code Online (Sandbox Code Playgroud)

与CSS检测和JS结果有区别,我有这个元:

<meta content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, width=device-width" name="viewport"/> 
Run Code Online (Sandbox Code Playgroud)

我想这是由于滚动条(15像素).我怎么能做得更好?

javascript jquery media-queries

50
推荐指数
3
解决办法
4万
查看次数

YQL和javascript(失败)

我发现了一个诡计

// Define variables
var query = 'select * from data.html.cssselect where url="http://www.chucknorrisfacts.com/chuck-norris-top-50-facts" and css=".field-content a"';
var yqlAPI = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + ' &format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=?';
$.getJSON(yqlAPI, function(r){
    console.log('Chuck Norris Facts:');
$.each(r.query.results.results.a, function(){ console.log('----------'); console.log(this.content);
}); }); 
Run Code Online (Sandbox Code Playgroud)

听起来很棒,但它不起作用.

发现这个:http://tutorialzine.com/2010/02/feed-widget-jquery-css-yql/同样的问题. https://github.com/hail2u/jquery.query-yql下载,解压缩,在服务器上运行,什么都没有.

第一个查询的YQL控制台很慢但有效.

如何在js中使用YQL?OAuth是否必要?

更新: 用控制台截图

javascript jquery yql

12
推荐指数
1
解决办法
792
查看次数

HTML/CSS中的像素字体

我尝试来自http://www.fontsquirrel.com/fonts/list/style/Pixel的像素字体,但它在浏览器中并不完美,禁用抗锯齿功能不是官方的CSS属性(或者找不到好的样本).

我发现了这个老问题:当使用@ font-face和像素字体时,是否可以在CSS中禁用消除锯齿功能?

而这个JS http://devpro.it/pixelfont/看起来非常好但是默认字体是小的(使我自己的字体不是一个很好的交易).所以我想知道是否有新的或其他提示(没有swf).

这是一个使用font-face的测试(在webkit上,firefox没有?):http://b4d455.fr/font/

html5 fonts pixel

8
推荐指数
2
解决办法
1万
查看次数

HTML关闭标签后整理新的空行

当我在Coda中使用Tidy HTML时它很干净,但我不喜欢空行

<ul>
    <li>…</li>
<!-- here -->
    <li>…</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

我尝试编辑配置但没有成功

// config file for Coda PHP Toolkit Tidy FORMAT script
// http://www.chipwreck.de/blog/software/coda-php
//
// documentation is here: http://tidy.sourceforge.net/#docs
// rev 5

anchor-as-name: no
doctype: auto
drop-empty-paras: no
fix-uri: no
literal-attributes: yes
merge-divs: no
merge-spans: no
numeric-entities: no
preserve-entities: yes
quote-ampersand: no
quote-marks: no
show-body-only: no
indent: auto
indent-spaces: 4
tab-size: 4
wrap: 0
wrap-asp: no
wrap-jste: no
wrap-php: no
wrap-sections: no
tidy-mark: no
new-blocklevel-tags: article,aside,command,canvas,dialog,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,meter 
new-inline-tags: …
Run Code Online (Sandbox Code Playgroud)

htmltidy coda

5
推荐指数
2
解决办法
2595
查看次数

删除开头的空行

我尝试删除空白行

    <--- space or empty line 
lorem ipsum 
---empty line----
dolores
Run Code Online (Sandbox Code Playgroud)

到此( ipsum 之后有一个空行)

lorem ipsum 
---empty line----
dolores
Run Code Online (Sandbox Code Playgroud)

我做了这个功能,它可以工作,但是我可以用 regex 做得更好吗?

$lines=explode("\n", $content);
function clean($l){
  if(trim($l['0'])==''){
    array_shift($l);
    return clean($l);
  } 
    return $l;
 } 
$content=implode("\n",clean($lines));
Run Code Online (Sandbox Code Playgroud)

php regex

2
推荐指数
1
解决办法
1231
查看次数

标签 统计

javascript ×2

jquery ×2

coda ×1

fonts ×1

html5 ×1

htmltidy ×1

media-queries ×1

php ×1

pixel ×1

regex ×1

yql ×1