为什么我在控制台中收到此错误?
拒绝执行" https://www.googleapis.com/customsearch/v1?key=API_KEY&q=flower&searchType=image&fileType=jpg&imgSize=small&alt=json "中的脚本,因为其MIME类型('application/json')不可执行,并且严格的MIME类型检查已启用.
我正在尝试让谷歌地图响应并调整大小,同时在Windows调整大小时保持其中心.我读了其他堆栈问题,例如:
响应式谷歌地图?和中心谷歌地图(V3)在浏览器调整大小(响应)
从第二个堆栈问题我得到一个链接,帮助我部分代码,但我仍然没有运气.这是我正在使用的代码,当我调整窗口大小时,地图根本不会调整大小
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(40.5472,12.282715),
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.addDomListener(window, "resize", function() {
var center = map.getCenter();
google.maps.event.trigger(map, "resize");
map.setCenter(center);
});
Run Code Online (Sandbox Code Playgroud)
HTML
<div id="map-canvas"/>
Run Code Online (Sandbox Code Playgroud)
CSS
html { height: 100% }
body { height: 100%; margin: 0; padding: 0; }
#map-canvas { height: 100%; }
Run Code Online (Sandbox Code Playgroud) 我试图在没有ul和li的情况下输出一个wp菜单,并在元素中添加了一个类.
我试过在我的function.php中添加这个
function add_menuclass($ulclass) {
return preg_replace('/<a /', '<a class="list-group-item"', $ulclass, 1);
}
add_filter('wp_nav_menu','add_menuclass');
Run Code Online (Sandbox Code Playgroud)
在我的模板中,我有:
<?php
$menuParameters = array(
'menu' => 'Videos',
'container' => false,
'echo' => false,
'items_wrap' => '%3$s',
'depth' => 0,
);
echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' );
?>
Run Code Online (Sandbox Code Playgroud)
但是输出只将类应用于第一个项而不是所有的<a>
s按预期方式.
<div class="list-group">
<a class="list-group-item" href="#">First item</a>
<a href="#">Second item</a>
</div>
Run Code Online (Sandbox Code Playgroud)
我试图实现这一点,基本上将该类应用于我的所有项目(不知道为什么它只适用于一个) - 请不要jQuery.
<div class="list-group">
<a class="list-group-item" href="#">First item</a>
<a class="list-group-item" href="#">Second item</a>
</div>
Run Code Online (Sandbox Code Playgroud) 除非我height: 100%
从body和html中删除,否则以下内容将无效.但是,我需要这种风格,因为我将它用于页面上的其他元素.
HTML
<a href="#" id="scrollTop">Back to top</a>
Run Code Online (Sandbox Code Playgroud)
jQuery的
$("#scrollTop").on("click",function(e){
e.preventDefault();
$(window).animate({scrollTop: 0}, 'slow');
});
Run Code Online (Sandbox Code Playgroud)
甚至尝试了以下仍有负面结果
$("#scrollTop").on("click",function(e){
e.preventDefault();
$("body, html").animate({scrollTop: 0}, 'slow');
});
Run Code Online (Sandbox Code Playgroud)
CSS
html, body {height:100%; min-height:100%;}
Run Code Online (Sandbox Code Playgroud) 我正在尝试为智能手机方向和桌面设置不同的媒体查询,我想要定位肖像和风景.我知道所有其他堆栈链接,如:
媒体查询定位大多数智能手机 3媒体查询的iphone肖像,风景和ipad肖像
但是我仍然遇到问题,我的情况不起作用,这是我正在使用的代码:
Desktop css first
-- csss for desk --
Portrait:
@media only screen and (min-device-width: 320px) and (max-device-width: 479px) {
body {
padding: 0 !important;
}
.infoShowWrapper {
width: 268px;
}
.heroImage {
margin-top: 0;
height: 200px;
width: 100%;
background: #fff url(assets/images/hero_small.jpg) no-repeat center center;
}
.navbar-fixed-top {
margin: 0 !important;
}
.box-item {
width: 280px;
}
.seaBkg {
background-image: url(assets/images/mare_2x.jpg);
}
}
Landscape:
@media only screen and (min-device-width: 480px) and (max-device-width: 640px) {
body {
padding: …
Run Code Online (Sandbox Code Playgroud) 我首先说我不是 100% 确定这是问题所在,我的意思是使用 await 和 async。
这是场景:
我在第一次加载页面时运行它,并且工作正常,我得到data
:
externalContent(url);
function externalContent(url) {
fetch(url)
.then(res => res.json())
.then(data => {
...cool data...
});
}
Run Code Online (Sandbox Code Playgroud)
但随后我需要能够单击一个按钮并重新运行该功能 fetch
所以我做
$(".alm-filters--button").on("click", function() {
externalContent(url);
});
Run Code Online (Sandbox Code Playgroud)
但是当我点击时,它给了我一个错误 .then(res => res.json())
错误说:未捕获(承诺)类型错误:无法读取未定义的属性“then”
我相信有一个异步问题,我试过了,但我对使用 async 和 await 还不够了解,但我试过:
async function externalContent(url) {
await fetch(url)
.then(res => res.json())
.then(data => {
...cool data...
});
}
Run Code Online (Sandbox Code Playgroud)
但是,我得到了同样的错误。
标题几乎说了一切,我确实从砌体中查看了图像插件但我没有运气,我想知道是否有人可以提供帮助?
脚本做了很多事情,它有过滤器位,动画,显示/隐藏,ajax来获取内容等等.如果有人可以调查它为什么重叠以及我如何能够基于它解决它,我会很高兴.代码如下:
jQuery(function(){
jQuery('#container').masonry({
itemSelector: '.box',
animate: true
});
});
(function ($) {
// Get all menu items with IDs starting with "filter-" and loop over them
$(".menu li[id|=filter]").each(function () {
// Get the ID add extract the page class name from it (remove "filter-" from it)
var type = $(this).attr("id").replace("filter-", "");
// Get the items in the "webbies" list with that class name
var items = $("#container div[class~=" + type + "]");
// Don't do anything if there aren't …
Run Code Online (Sandbox Code Playgroud) 使用绝对值时,它会滚动但不会达到100%的高度:
.class {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
height: 100%;
width: 100%;
z-index: 1000000;
background: rgba(0, 0, 0, 0.9);
}
Run Code Online (Sandbox Code Playgroud)
固定后,它的高度为100%,但不会滚动
.class {
position: fixed;
left: 0;
top: 0;
height: 100%;
width: 100%;
z-index: 1000000;
background: rgba(0, 0, 0, 0.9);
}
Run Code Online (Sandbox Code Playgroud)
我想避免在子元素中添加固定的高度并制作它 overflow: scroll
按照我之前的问题谷歌地图响应调整大小我想基于Windows调整大小实现不同的缩放级别,同时调整大小,所以如果浏览器窗口"小于"应用x数量的缩放,如果"主要比"应用另一个缩放级别自动和即时.
以下代码完美地适用于在Windows调整大小上重新定位地图,我需要将新的缩放级别应用于它:
var map;
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(40.5472,12.282715),
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.addDomListener(window, "resize", function() {
var center = map.getCenter();
google.maps.event.trigger(map, "resize");
map.setCenter(center);
map.setZoom(zoom level needs to be automatically set according to window size);
});
Run Code Online (Sandbox Code Playgroud) 我正在使用twitter,facebook和google +的以下内容,但是linkedin给了我一个错误对话框:
<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'http://www.twitter.com/share?url=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Share on Twitter"><span class="character">a</span></a>
<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Share on Facebook"><span class="character">b</span></a>
<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'https://plus.google.com/share?url=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Share on Google+"><span class="character">c</span></a>
<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'https://www.linkedin.com/share?url=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Share on Google+"><span class="character">j</span></a>
Run Code Online (Sandbox Code Playgroud)
错误
此XML文件似乎没有与之关联的任何样式信息.文档树如下所示. …
javascript ×7
jquery ×5
css3 ×2
async-await ×1
css ×1
ecmascript-6 ×1
google-maps ×1
json ×1
linkedin ×1
php ×1
wordpress ×1