GVKun编程网logo

我的代码在 Blogger 中有效,但在 wordpress 中无效(wordpress代码库 – 专注wordpress的实用资源)

3

本文将分享我的代码在Blogger中有效,但在wordpress中无效的详细内容,并且还将对wordpress代码库–专注wordpress的实用资源进行详尽解释,此外,我们还将为大家带来关于'inn

本文将分享我的代码在 Blogger 中有效,但在 wordpress 中无效的详细内容,并且还将对wordpress代码库 – 专注wordpress的实用资源进行详尽解释,此外,我们还将为大家带来关于'innerText' 在 IE 中有效,但在 Firefox 中无效、(ajax, jquery) 自动完成在 chrome 中有效,但在 opera 中无效、BS 5.0.2 - 防止下拉菜单的默认行为 - 在 BS4 中有效,但在 BS5 中无效、CSS 边框图像关键帧动画在 Firefox 中有效,但在 Chrome 中无效的相关知识,希望对你有所帮助。

本文目录一览:

我的代码在 Blogger 中有效,但在 wordpress 中无效(wordpress代码库 – 专注wordpress的实用资源)

我的代码在 Blogger 中有效,但在 wordpress 中无效(wordpress代码库 – 专注wordpress的实用资源)

如何解决我的代码在 Blogger 中有效,但在 wordpress 中无效

先生,我的代码在 Blogger 中正常运行,但在 wordpress 中不起作用。我是初学者,所以请帮助解决问题。请进行一些必要的更改以使其正常运行。

<style>
.button {
    background-image: linear-gradient(to right,#0066ff,#00a1ff,#00c6eb,#00e087,#a8eb12);
    border: 1px solid black;
    color: white;
    font-family: Arial;
    font-size: small;
    text-decoration: none;
    padding: 3px;
}
.techly360{
    background-image: linear-gradient(to right,#a8eb12);
    color: white;
}
</style>

<div>
<a href="#" id="download">Download File</a>

<button id="btn">Click to Download</button>

<script>
var downloadButton = document.getElementById("download");
var counter = 10;
var newElement = document.createElement("p");
newElement.innerHTML = "10 sec";
var id;

downloadButton.parentNode.replaceChild(newElement,downloadButton);

function startDownload() {
    this.style.display = ''none'';
    id = setInterval(function () {
        counter--;
        if (counter < 0) {
            newElement.parentNode.replaceChild(downloadButton,newElement);
            clearInterval(id);
        } else {
            newElement.innerHTML = +counter.toString() + " second.";
        }
    },1000);
};

var clickbtn = document.getElementById("btn");
clickbtn.onclick = startDownload;
</script>

解决方法

var downloadButton = document.getElementById("download");
var counter = 10;
var newElement = document.createElement("p");
newElement.innerHTML = "10 sec";
var id;

downloadButton.parentNode.replaceChild(newElement,downloadButton);

function startDownload() {
    this.style.display = ''none'';
    id = setInterval(function () {
        counter--;
        if (counter < 0) {
            newElement.parentNode.replaceChild(downloadButton,newElement);
            clearInterval(id);
        } else {
            newElement.innerHTML = +counter.toString() + " second.";
        }
    },1000);
};

var clickbtn = document.getElementById("btn");
clickbtn.onclick = startDownload;
.button {
    background-image: linear-gradient(to right,#0066ff,#00a1ff,#00c6eb,#00e087,#a8eb12);
    border: 1px solid black;
    color: white;
    font-family: Arial;
    font-size: small;
    text-decoration: none;
    padding: 3px;
}
.techly360{
    background-image: linear-gradient(to right,#a8eb12);
    color: white;
}
<div>
<a href="#" id="download">Download File</a>
<button id="btn">Click to Download</button>

,

WordPress 的工作结构是不同的。如果您将此代码用作 html 文件,则可以正常工作。像这样: https://file.io/4a0F1OL14avi

但在 wordpress 中你需要分离代码。 (就像图片一样) 1-复制帖子内容中的html代码 2-复制header.php中的样式和脚本(在主题的根目录中)

enter image description here

'innerText' 在 IE 中有效,但在 Firefox 中无效

'innerText' 在 IE 中有效,但在 Firefox 中无效

我有一些适用于 IE 的 JavaScript 代码,其中包含以下内容:

myElement.innerText = "foo";

但是,似乎 ‘innerText’ 属性在 Firefox 中不起作用。有一些 Firefox 等价物吗?还是可以使用更通用的跨浏览器属性?

答案1

小编典典

Firefox 使用符合W3C 的
textContent属性。

我猜 Safari 和 Opera 也支持这个属性。

(ajax, jquery) 自动完成在 chrome 中有效,但在 opera 中无效

(ajax, jquery) 自动完成在 chrome 中有效,但在 opera 中无效

如何解决(ajax, jquery) 自动完成在 chrome 中有效,但在 opera 中无效

我正在做一个字典项目。

有谁明白为什么这个自动完成功能(在互联网上找到并改编了它)在 Chrome 中有效,但在 Opera 中无效(也没有错误消息)?

我通过 JS 将两个值(语言选择和搜索查询)传递给 PHP。

HTML

            <form action="showresults.PHP" method="GET">
                    
                
                  <select name="lang" id="lang_select">     
                     
                    <option value="de" <?PHP if ($lang=="de") { echo "SELECTED";} ?>>Deutsch</option>
                    <option value="it" <?PHP if ($lang=="it") { echo "SELECTED";} ?>>Italiano</option>
                    <option value="en" <?PHP if ($lang=="en") { echo "SELECTED";} ?>>English</option>
                   </select>
                
                  
            <input type="text" name="query" id="search" placeholder="keyword(s)" autocomplete="off" required> 
            <input type="submit" value="search">
            </form>

JS

$(document).ready(function () {

  // Send Search Text to the server
  $("#search").keyup(function () {
    let searchText = $(this).val();
    var lang = $("#lang_select").val();
    if (searchText != "") {
    
      $.ajax({
        url: "action.PHP",method: "get",data: {
          query: searchText,lang: lang
        },success: function (response) {
          $("#show-list").html(response);
        },});
    } else {
      $("#show-list").html("");
    }
  });
  // Set searched text in input field on click of search button
  $(document).on("click","a",function () {
    $("#search").val($(this).text());
    $("#show-list").html("");
  });
});

非常感谢!!!

BS 5.0.2 - 防止下拉菜单的默认行为 - 在 BS4 中有效,但在 BS5 中无效

BS 5.0.2 - 防止下拉菜单的默认行为 - 在 BS4 中有效,但在 BS5 中无效

如何解决BS 5.0.2 - 防止下拉菜单的默认行为 - 在 BS4 中有效,但在 BS5 中无效

在 BS4 中,我能够执行类似于以下操作(尽管在 jquery 中)以防止基于满足条件的下拉列表。在 5.0.2 中,这似乎没有任何作用,下拉菜单仍然正常显示/隐藏。它现在不尊重 stopPropagation() 和 preventDefault() 还是现在需要以不同的方式处理?

  1. document.querySelectorAll(''.dropdown [data-bs-toggle="dropdown"]'').forEach(function(dd) {
  2. dd.addEventListener(''click'',function(e) {
  3. if( *some condition met* ) {
  4. e.stopPropagation();
  5. e.preventDefault();
  6. }
  7. });
  8. });

在有人问之前......是的,我的条件得到了满足,这不是这里的问题。

解决方法

根据 OP 的 jsfiddle 示例修改答案

BS4 版本响应点击的 preventDefault() 并没有阻止 Bootstrap 的下拉,而是阻止了 Dallaslu’s multi-level dropdown –(Dallaslu 的代码触发了下拉切换)。

Dallaslu 确实有一个 Bootstrap 5 multi-level dropdown,在更新代码以使用 data-bs-dropend 而不是 dropright 后,它可以与 jsFiddle 中的菜单配合使用。

  1. (function($bs) {
  2. const CLASS_NAME = ''has-child-dropdown-show'';
  3. $bs.Dropdown.prototype.toggle = function(_orginal) {
  4. return function() {
  5. document.querySelectorAll(''.'' + CLASS_NAME).forEach(function(e) {
  6. e.classList.remove(CLASS_NAME);
  7. });
  8. let dd = this._element.closest(''.dropdown'').parentNode.closest(''.dropdown'');
  9. for (; dd && dd !== document; dd = dd.parentNode.closest(''.dropdown'')) {
  10. dd.classList.add(CLASS_NAME);
  11. }
  12. return _orginal.call(this);
  13. }
  14. }($bs.Dropdown.prototype.toggle);
  15. document.querySelectorAll(''.dropdown'').forEach(function(dd) {
  16. dd.addEventListener(''hide.bs.dropdown'',function(e) {
  17. if (this.classList.contains(CLASS_NAME)) {
  18. this.classList.remove(CLASS_NAME);
  19. e.preventDefault();
  20. }
  21. if (e.clickEvent && e.clickEvent.composedPath().some(el => el.classList && el.classList.contains(''dropdown-toggle''))) {
  22. e.preventDefault();
  23. }
  24. e.stopPropagation(); // do not need pop in multi level mode
  25. });
  26. });
  27. // for hover
  28. function getDropdown(element) {
  29. return $bs.Dropdown.getInstance(element) || new $bs.Dropdown(element);
  30. }
  31. document.querySelectorAll(''.dropdown-hover,.dropdown-hover-all .dropdown'').forEach(function(dd) {
  32. dd.addEventListener(''mouseenter'',function(e) {
  33. let toggle = e.target.querySelector('':scope>[data-bs-toggle="dropdown"]'');
  34. if (!toggle.classList.contains(''show'')) {
  35. getDropdown(toggle).toggle();
  36. }
  37. });
  38. dd.addEventListener(''mouseleave'',function(e) {
  39. let toggle = e.target.querySelector('':scope>[data-bs-toggle="dropdown"]'');
  40. if (toggle.classList.contains(''show'')) {
  41. getDropdown(toggle).toggle();
  42. }
  43. });
  44. });
  45. })(bootstrap);
  1. /* ============ MOBILE VERSION OF THE HEADER NAV ============ */
  2. /* ============ HEADER AND LOGO ============ */
  3. #header {
  4. background-color: #000;
  5. font-weight: 400;
  6. padding: 0 1rem;
  7. font-size: 1rem;
  8. }
  9. /*logo*/
  10. #header .navbar-brand {
  11. margin: auto;
  12. padding: .5625rem 1.625rem .5625rem 0;
  13. /*this centers the logo correctly as it is the width of the toggler*/
  14. }
  15. /*bottom spacing for entire dropdown menu*/
  16. #header .navbar-nav {
  17. margin-bottom: 1rem;
  18. }
  19. /* ============ SPECIAL MENU STUFF ============ */
  20. /*navbar check for jquery*/
  21. #navbar-check {
  22. display: none;
  23. }
  24. /*smart header hide/show*/
  25. .navbar-showhide {
  26. position: fixed;
  27. top: 0;
  28. right: 0;
  29. left: 0;
  30. z-index: 1030;
  31. }
  32. .navbar-showhide.scrolled-down {
  33. transform: translateY(-100%);
  34. transition: all 0.2s ease-in-out;
  35. visibility: hidden;
  36. }
  37. .navbar-showhide.scrolled-up {
  38. transform: translateY(0);
  39. transition: all 0.2s ease-in-out;
  40. }
  41. #header .dropdown-menu.megaFull,#header .dropdown-menu.megaLg {
  42. padding: .5rem 2rem 0;
  43. }
  44. #header .dropdown-menu.megaSub {
  45. padding: .5rem 3rem 0;
  46. }
  47. #header .dropdown-title {
  48. font-weight: 600;
  49. color: white;
  50. font-size: .9375rem;
  51. margin: 0 0 .5rem;
  52. }
  53. /* ============ MENU ============ */
  54. /*top links container*/
  55. #header .nav-item {
  56. border-radius: .3rem;
  57. }
  58. /*top links*/
  59. #header .nav-link,#header .nav-link:focus {
  60. padding: .5rem 1rem;
  61. color: gray;
  62. }
  63. #header .nav-link:hover {
  64. color: #fff;
  65. }
  66. /*top dropdown link solid color when open*/
  67. #header .dropdown .dropdown-toggle[aria-expanded=true] {
  68. color: #fff;
  69. }
  70. /*dropdown arrows - remove bootstrap default*/
  71. #header .dropdown .dropdown-toggle:after {
  72. border: 0;
  73. vertical-align: 0;
  74. margin: 0;
  75. }
  76. /*add custom dropdown arrows*/
  77. #header .dropdown .dropdown-toggle[aria-expanded=false]:after {
  78. font-family: ''Font Awesome 5 Free'';
  79. content: ''\\f107'';
  80. /*fal fa-angle-down*/
  81. font-weight: 600;
  82. margin-left: .5rem;
  83. display: inline-block;
  84. }
  85. #header .dropdown .dropdown-toggle[aria-expanded=true]:after {
  86. font-family: ''Font Awesome 5 Free'';
  87. content: ''\\f106'';
  88. /*fal fa-angle-up*/
  89. font-weight: 600;
  90. margin-left: .5rem;
  91. display: inline-block;
  92. }
  93. /*dropdown box*/
  94. #header .dropdown-menu {
  95. margin: 0;
  96. padding: 0;
  97. background-color: transparent;
  98. border-color: transparent;
  99. }
  100. /*dropdown box links inside*/
  101. #header .dropdown-item {
  102. font-weight: 300;
  103. font-size: .9375rem;
  104. color: #ccc;
  105. padding: .25rem 2rem;
  106. }
  107. #header .dropdown-item:active,#header .dropdown-item:focus,#header .dropdown-item:hover,#header .dropdown .dropdown .dropdown-toggle[aria-expanded=true] {
  108. /*this keeps the open dropdown link solid*/
  109. background-color: transparent;
  110. }
  111. #header .dropdown-item:hover {
  112. color: #fff;
  113. }
  114. /*two levels*/
  115. #header .dropdown-menu .dropdown-menu .dropdown-item {
  116. padding: .25rem 3rem;
  117. }
  118. /*three levels*/
  119. #header .dropdown-menu .dropdown-menu .dropdown-menu .dropdown-item {
  120. padding: .25rem 4rem;
  121. }
  122. /*right side nav buttons*/
  123. #header .ml-lg-auto .nav-item+.nav-item {
  124. margin-top: .25rem;
  125. }
  126. #header .ml-lg-auto .nav-link,#header .ml-lg-auto .nav-link:active,#header .ml-lg-auto .nav-link:focus,#header .ml-lg-auto .nav-link:hover {
  127. color: #fff !important;
  128. font-weight: 600;
  129. }
  130. /*blue dropdown*/
  131. #header .dropBlue {
  132. background-color: #347fc0;
  133. }
  134. /*green dropdown*/
  135. #header .dropGreen {
  136. background-color: #4fab4f;
  137. }
  138. /*form stuff*/
  139. #header .dropForm .dropdown-menu {
  140. padding: 0 1.5rem 1rem;
  141. color: #fff;
  142. }
  143. #header .dropForm .dropdown-title {
  144. font-weight: 600;
  145. color: #fff;
  146. margin: 1rem 0 1rem;
  147. }
  148. /*remember me*/
  149. #header .custom-control-label {
  150. font-size: .9375rem;
  151. }
  152. #header .custom-checkbox .custom-control-label::before {
  153. border: 0;
  154. }
  155. /*in misc so it works on all pages*/
  156. .custom-control-label::after {
  157. top: .2rem;
  158. }
  159. #header .custom-control-input:focus~.custom-control-label::before {
  160. box-shadow: none;
  161. }
  162. #header .custom-control-label::before {
  163. background-color: #fff;
  164. }
  165. #header .custom-checkbox .custom-control-input:checked~.custom-control-label::before {
  166. background-color: darken(#347fc0,10%);
  167. }
  168. /*the toggler*/
  169. #header .navbar-toggler {
  170. font-size: 1.750rem;
  171. /*makes a 26px (with padding) wide fontawesome icon*/
  172. }
  173. #header .navbar-toggler,#header .navbar-toggler.collapsed:hover {
  174. color: #4fab4f;
  175. }
  176. /*when menu is closed and not hovered*/
  177. #header .navbar-toggler.collapsed {
  178. color: #fff;
  179. }
  180. /* ============ DESKTOP VERSION OF THE HEADER NAV ============ */
  181. @media only screen and (min-width: 992px) {
  182. /* ============ HEADER AND LOGO ============ */
  183. /*bottom spacing for entire dropdown menu*/
  184. #header .navbar-nav {
  185. margin-bottom: 0;
  186. }
  187. /* ============ SPECIAL MENU STUFF ============ */
  188. /*navbar check for jquery*/
  189. #navbar-check {
  190. display: block;
  191. }
  192. /*smart header hide/show*/
  193. .navbar-showhide.scrolled-down .dropdown-menu {
  194. opacity: 0 !important;
  195. visibility: hidden;
  196. transition: all 0.2s ease-in-out;
  197. }
  198. #header .hasmegaFull {
  199. position: static !important;
  200. }
  201. #header .megaFull {
  202. left: 0;
  203. right: 0;
  204. width: 100%;
  205. }
  206. #header .megaSub {
  207. left: 100%;
  208. top: 0;
  209. min-height: 100%;
  210. }
  211. #header .dropdown-menu.megaFull,#header .dropdown-menu.megaSub,#header .dropdown-menu.megaLg {
  212. padding: 1rem;
  213. color: #bfe1ff;
  214. }
  215. #header .dropdown-title {
  216. font-weight: 600;
  217. color: #fff;
  218. }
  219. /* ============ MENU ============ */
  220. /*top links container*/
  221. #header .nav-item {
  222. border-radius: 0;
  223. }
  224. /*top links*/
  225. #header .nav-link,#header .nav-link:focus {
  226. padding: 1.125rem 1rem;
  227. color: #ccc;
  228. /*top link and dropdown menu transition should match*/
  229. /*transition: all .15s ease-in-out;*/
  230. }
  231. #header .nav-link:hover {
  232. color: #fff;
  233. background-color: #4fab4f;
  234. }
  235. /*top link colors*/
  236. #header .dropBlue .nav-link,#header .dropBlue .dropdown .dropdown-toggle[aria-expanded="true"],#header .dropBlue .dropdown-menu {
  237. background-color: #347fc0 !important;
  238. border-color: #347fc0;
  239. }
  240. #header .dropGreen .nav-link,#header .dropGreen .dropdown .dropdown-toggle[aria-expanded="true"],#header .dropGreen .dropdown-menu {
  241. background-color: #4fab4f !important;
  242. border-color: #4fab4f;
  243. }
  244. /*top dropdown link solid color when open*/
  245. #header .dropdown .dropdown-toggle[aria-expanded=true] {
  246. color: #fff;
  247. background-color: #4fab4f;
  248. }
  249. /*top links remove dropdown arrow*/
  250. #header .dropdown .dropdown-toggle[aria-expanded="false"]:after,#header .dropdown .dropdown-toggle[aria-expanded="true"]:after {
  251. content: '''';
  252. font-family: inherit;
  253. margin: 0;
  254. }
  255. /*add custom dropdown arrows for submenus*/
  256. #header .dropdown .dropdown .dropdown-toggle[aria-expanded="false"]:after {
  257. font-family: ''Font Awesome 5 Free'';
  258. content: ''\\f105'';
  259. /*fal fa-angle-right*/
  260. font-weight: 600;
  261. margin-left: .5rem;
  262. display: inline-block;
  263. float: right;
  264. }
  265. #header .dropdown .dropdown .dropdown-toggle[aria-expanded="true"]:after {
  266. font-family: ''Font Awesome 5 Free'';
  267. content: ''\\f104'';
  268. /*fal fa-angle-left*/
  269. font-weight: 600;
  270. margin-left: .5rem;
  271. display: inline-block;
  272. float: right;
  273. }
  274. /*dropdown*/
  275. #header .dropdown-menu {
  276. background-color: #4fab4f;
  277. border-radius: .5rem;
  278. border-top-left-radius: 0;
  279. border-top-right-radius: 0;
  280. padding: .5rem .35rem;
  281. /*hover doesn''t like this*/
  282. /*padding: .5rem 0;*/
  283. border-color: #4fab4f;
  284. border-top: 0;
  285. /*top link and dropdown menu transition should match*/
  286. /* display: block;
  287. opacity: 0;
  288. pointer-events: none;
  289. transition: all .15s ease-in-out;
  290. */
  291. }
  292. #header .show>.dropdown-menu {
  293. pointer-events: auto;
  294. opacity: 1;
  295. }
  296. #header .dropdown-menu li {
  297. position: relative;
  298. }
  299. #header .dropdown-menu li.hasmegaSub {
  300. position: relative;
  301. }
  302. /*dropdown box links inside regular*/
  303. #header .dropdown-item {
  304. color: #fff;
  305. padding: .3125rem .65rem;
  306. /*hover doesn''t like this*/
  307. /*padding:.3125rem 1rem;*/
  308. border-radius: 0.5rem;
  309. /*hover doesn''t like this*/
  310. /*border-radius: 0;*/
  311. }
  312. #header .dropdown-item:active,/*#header .dropdown-item:focus,*/
  313. /*when on it leaves submenu link highlighted even when its submenu is closed*/
  314. #header .dropdown-item:hover,#header .dropdown .dropdown .dropdown-toggle[aria-expanded="true"] {
  315. color: #fff;
  316. background-color: lighten(#4fab4f,7%);
  317. }
  318. /*multi level*/
  319. #header .dropdown-menu .dropdown-menu {
  320. border-radius: .5rem;
  321. border: 1px solid darken(#4fab4f,5%);
  322. top: calc(-.5rem - 1px);
  323. /*use calc when using border on these boxes - 1px covers border and .5rem is the top padding of the box*/
  324. /*left: calc(100% - .25rem);*/
  325. /*use to shift box a little to the left to overlap the previous*/
  326. }
  327. #header .dropdown-menu .dropdown-menu .dropdown-item,#header .dropdown-menu .dropdown-menu .dropdown-menu .dropdown-item {
  328. padding: .3125rem .65rem;
  329. /*hover doesn''t like this*/
  330. /*padding:.3125rem 1rem;*/
  331. }
  332. /*right side nav buttons*/
  333. #header .ml-lg-auto .nav-item+.nav-item {
  334. margin-top: 0;
  335. }
  336. /*form stuff*/
  337. #header .dropForm .dropdown-menu {
  338. padding: 0 1rem 1rem;
  339. min-width: 17.875rem;
  340. }
  341. }
  1. <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"/>
  2. <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet"/>
  3. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
  4. <div id="wrapper">
  5. <!-- BEGIN NAVBAR -->
  6. <nav id="header" class="navbar navbar-expand-lg navbar-showhide dropdown-hover-all">
  7. <div class="container" style="position: relative;">
  8. <button class="navbar-toggler collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
  9. <i class="fas fa-bars"></i>
  10. </button>
  11. <a class="navbar-brand" href="/">
  12. <img alt="test" src="https://via.placeholder.com/80x42.png" height="42">
  13. </a>
  14. <div id="navbar" class="navbar-nav-scroll collapse navbar-collapse">
  15. <ul class="navbar-nav">
  16. <li class="nav-item">
  17. <a class="nav-link" href="/test/">Regular Link</a>
  18. </li>
  19. <li class="nav-item dropdown">
  20. <a id="dropdown01" class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">test no link</a>
  21. <ul class="dropdown-menu" aria-labelledby="dropdown01">
  22. <li><a class="dropdown-item" href="/test/">one</a></li>
  23. <li class="dropdown dropend">
  24. <a id="dropdown02" class="dropdown-item dropdown-toggle" href="/test/" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">test with link</a>
  25. <ul class="dropdown-menu" aria-labelledby="dropdown02">
  26. <li><a class="dropdown-item" href="/test/">one</a></li>
  27. <li class="dropdown dropend">
  28. <a id="dropdown03" class="dropdown-item dropdown-toggle" href="/test/" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">test with link</a>
  29. <ul class="dropdown-menu" aria-labelledby="dropdown03">
  30. <li><a class="dropdown-item" href="/test/">one</a></li>
  31. <li><a class="dropdown-item" href="/test/">two</a></li>
  32. <li><a class="dropdown-item" href="/test/">three</a></li>
  33. </ul>
  34. </li>
  35. <li><a class="dropdown-item" href="/test/">three</a></li>
  36. </ul>
  37. </li>
  38. <li><a class="dropdown-item" href="/test/">two</a></li>
  39. </ul>
  40. </li>
  41. <li class="nav-item dropdown">
  42. <a id="DD_megaSub" class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">megaSub no link</a>
  43. <ul class="dropdown-menu" aria-labelledby="DD_megaSub">
  44. <li><a class="dropdown-item" href="/test/">test</a></li>
  45. <li class="dropdown dropend hasmegaSub">
  46. <a id="DD_Mega4" class="dropdown-item dropdown-toggle" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">test no link</a>
  47. <div class="dropdown-menu megaSub" style="min-width:400px;" aria-labelledby="DD_Mega4">
  48. <div class="row row-cols-1 row-cols-sm-2">
  49. <div class="col pb-3 pb-sm-1 pb-lg-0">
  50. <h6 class="dropdown-title">Title Menu One</h6>
  51. <ul class="list-unstyled">
  52. <li><a href="/test/">Submenu item</a></li>
  53. <li><a href="/test/">Submenu item</a></li>
  54. <li><a href="/test/">Submenu item</a></li>
  55. <li><a href="/test/">Submenu item</a></li>
  56. <li><a href="/test/">Submenu item</a></li>
  57. </ul>
  58. </div>
  59. <div class="col pb-1 pb-lg-0">
  60. <h6 class="dropdown-title">Title Menu Two</h6>
  61. <ul class="list-unstyled">
  62. <li><a href="/test/">Submenu item</a></li>
  63. <li><a href="/test/">Submenu item</a></li>
  64. <li><a href="/test/">Submenu item</a></li>
  65. <li><a href="/test/">Submenu item</a></li>
  66. </ul>
  67. </div>
  68. </div>
  69. </div>
  70. </li>
  71. <li class="dropdown">
  72. <a id="DD_Mega5" class="dropdown-item dropdown-toggle" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">test no link</a>
  73. <div class="dropdown-menu megaSub" style="min-width:400px;" aria-labelledby="DD_Mega5">
  74. <div class="row row-cols-1 row-cols-sm-2">
  75. <div class="col pb-3 pb-sm-1 pb-lg-0">
  76. <h6 class="dropdown-title">Title Menu One</h6>
  77. <ul class="list-unstyled">
  78. <li><a href="/test/">Submenu item</a></li>
  79. <li><a href="/test/">Submenu item</a></li>
  80. <li><a href="/test/">Submenu item</a></li>
  81. <li><a href="/test/">Submenu item</a></li>
  82. <li><a href="/test/">Submenu item</a></li>
  83. </ul>
  84. </div>
  85. <div class="col pb-1 pb-lg-0">
  86. <h6 class="dropdown-title">Title Menu Two</h6>
  87. <ul class="list-unstyled">
  88. <li><a href="/test/">Submenu item</a></li>
  89. <li><a href="/test/">Submenu item</a></li>
  90. <li><a href="/test/">Submenu item</a></li>
  91. <li><a href="/test/">Submenu item</a></li>
  92. </ul>
  93. </div>
  94. </div>
  95. </div>
  96. </li>
  97. </ul>
  98. </li>
  99. </ul>
  100. <ul class="navbar-nav ml-lg-auto">
  101. <li class="nav-item dropGreen"><a class="nav-link" href="/test/"><i class="fas fa-arrow-circle-right fa-pr"></i>regular link</a></li>
  102. <li class="nav-item dropdown dropForm dropBlue">
  103. <a id="DD_Login" class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-user-circle fa-pr"></i>form no link</a>
  104. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="DD_Login">
  105. <form class="" role="form" method="post" action="http://example.com" target="_blank" autocomplete="off">
  106. <h6 class="dropdown-title">Sign in to your account :</h6>
  107. <div class="form-group">
  108. <label class="sr-only" for="signinUsername">Username</label>
  109. <div class="input-group">
  110. <div class="input-group-prepend">
  111. <span class="input-group-text"><i class="fas fa-user fa-fw"></i></span>
  112. </div>
  113. <input id="signinUsername" type="text" class="form-control" name="username" placeholder="username" />
  114. </div>
  115. </div>
  116. <div class="form-group">
  117. <label class="sr-only" for="signinPassword">Password</label>
  118. <div class="input-group">
  119. <div class="input-group-prepend">
  120. <span class="input-group-text"><i class="fas fa-lock-alt fa-fw"></i></span>
  121. </div>
  122. <input id="signinPassword" type="password" class="form-control" name="password" placeholder="password" />
  123. </div>
  124. </div>
  125. <div class="custom-control custom-checkbox">
  126. <input id="rememberMe" type="checkbox" class="custom-control-input" value="1" name="remember">
  127. <label for="rememberMe" class="custom-control-label">Remember me?</label>
  128. </div>
  129. <div class="form-group mt-3 mb-0">
  130. <input type="hidden" name="signin" value="signin">
  131. <button type="submit" class="btn btn-success btn-block">Login Now</button>
  132. </div>
  133. </form>
  134. </div>
  135. </li>
  136. </ul>
  137. </div>
  138. </div>
  139. </nav>
  140. <!-- END NAVBAR -->
  141. </div>
  142. <!-- END WRAPPER -->
  143. <div id="navbar-check"></div>

我没有从您的 BS4 版本中添加用于处理触摸屏的代码,但该代码段确实显示了使用悬停的菜单。

我确实删除了一些菜单项,以便代码片段符合 Stackoverflow 的大小限制,但您仍然应该能够看到效果。

CSS 边框图像关键帧动画在 Firefox 中有效,但在 Chrome 中无效

CSS 边框图像关键帧动画在 Firefox 中有效,但在 Chrome 中无效

如何解决CSS 边框图像关键帧动画在 Firefox 中有效,但在 Chrome 中无效

我有一个带有梯度 divborder-image 和一个 animation 属性,它在关键帧中改变梯度的 deg(度)。

这在 Firefox 中非常有效,但在 Chrome 中则不然。事实上,在 Chrome 中,元素根本没有边框。就像浏览器在看到元素具有 animation 属性时简单地放弃一样。

这是一个小提琴:

https://jsfiddle.net/0nymc9ej/2/

  1. body {
  2. background: black;
  3. }
  4. div {
  5. color: white;
  6. width: 300px;
  7. height: 300px;
  8. border: 5px solid;
  9. border-image: linear-gradient(0deg,#ff0000,#00ff00,#0000ff) 1 / 5px;
  10. animation: move 1s infinite;
  11. }
  12. @keyframes move {
  13. 0% { border-image: linear-gradient(0deg,#0000ff) 1 / 5px; }
  14. 25% { border-image: linear-gradient(90deg,#0000ff) 1 / 5px; }
  15. 50% { border-image: linear-gradient(180deg,#0000ff) 1 / 5px; }
  16. 75% { border-image: linear-gradient(270deg,#0000ff) 1 / 5px; }
  17. 100% { border-image: linear-gradient(360deg,#0000ff) 1 / 5px; }
  18. }
  1. <div>This has a nice moving border in Firefox but not in Chrome</div>

  1. 为什么这在 Chrome 中不起作用,但在 Firefox 中起作用?
  2. 有没有什么方法可以在不使用伪元素、JavaScript 或其他黑客的情况下在 Chrome 中实现这一点?
  3. 有没有办法让渐变变化平滑地相互“淡入淡出”(而不是简单地添加更多关键帧),因为动画现在看起来真的很生涩?

解决方法

这是一个使用掩码的想法:

  1. body {
  2. background: black;
  3. }
  4. .box {
  5. color: white;
  6. width: 300px;
  7. height: 200px;
  8. position:relative;
  9. padding:5px; /* this will control the border width */
  10. overflow:hidden;
  11. }
  12. .box div{
  13. content:"";
  14. position:absolute;
  15. inset:0; /* shorthand of top right bottom left */
  16. padding: inherit;
  17. /* make the gradient visible only inside the padding area */
  18. -webkit-mask:
  19. linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0) padding-box;
  20. -webkit-mask-composite:destination-out;
  21. mask-composite:exclude;
  22. /**/
  23. }
  24. /* a rotating gradient layer */
  25. .box div::before{
  26. content:"";
  27. position:absolute;
  28. inset:-50%;
  29. background:linear-gradient(#ff0000,#00ff00,#0000ff);
  30. animation: move 1s infinite;
  31. }
  32. @keyframes move {
  33. 100% { transform:rotate(360deg); }
  34. }
  1. <div class="box">
  2. <div></div>
  3. This has a nice moving border</div>

在不久的将来,您可以使用如下所示的 CSS 变量来实现(目前仅适用于 Chrome 和 Edge)

  1. @property --a{
  2. syntax: ''<angle>'';
  3. inherits: false;
  4. initial-value: 0deg;
  5. }
  6. body {
  7. background: black;
  8. }
  9. div {
  10. color: white;
  11. width: 300px;
  12. height: 200px;
  13. border: 5px solid;
  14. --a:0deg; /* fallback for FF to see the border */
  15. border-image: linear-gradient(var(--a),#ff0000,#0000ff) 1 / 5px;
  16. animation: move 1s infinite;
  17. }
  18. @keyframes move {
  19. 100%{--a:360deg}
  20. }
  1. <div>This has a nice moving border</div>

我们今天的关于我的代码在 Blogger 中有效,但在 wordpress 中无效wordpress代码库 – 专注wordpress的实用资源的分享已经告一段落,感谢您的关注,如果您想了解更多关于'innerText' 在 IE 中有效,但在 Firefox 中无效、(ajax, jquery) 自动完成在 chrome 中有效,但在 opera 中无效、BS 5.0.2 - 防止下拉菜单的默认行为 - 在 BS4 中有效,但在 BS5 中无效、CSS 边框图像关键帧动画在 Firefox 中有效,但在 Chrome 中无效的相关信息,请在本站查询。

本文标签:

上一篇WordPress : 指挥官__trashed(《指挥官》)

下一篇在 Wordpress 管理区域中为自定义帖子类型创建自定义管理编辑页面(wordpress自定义内容模型)