小编hun*_*tar的帖子

使用仅带边距的部分垂直线分隔div

是否有可能只为包含文本的三个div设置边距?请注意,线条不如div高

在此输入图像描述

https://codepen.io/anon/pen/zzRXLM

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, …
Run Code Online (Sandbox Code Playgroud)

html css

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

jQuery nearest(),parents()和parent()会影响同一DOM级别的多个元素

我试图将DOM遍历到最近的DIV.下面的标记如下.

<div>
     <span>
           <a class="anchor">Text</a>
     </span>
</div>
<div>
     <span>
           <a class="anchor">Text</a>
     </span>
</div>
<div>
     <span>
           <a class="anchor">Text</a>
     </span>
</div>
Run Code Online (Sandbox Code Playgroud)

当我使用以下任何一项时:

$('.anchor').closest('div').css('background-color', 'red');
$('.anchor').parents('div').css('background-color', 'red');
$('.anchor').parent().parent().css('background-color', 'red');
Run Code Online (Sandbox Code Playgroud)

它影响所有的DIV,如下所示:

<div style="background-color: red">
     <span>
           <a class="anchor">Text</a>
     </span>
</div>
<div style="background-color: red">
     <span>
           <a class="anchor">Text</a>
     </span>
</div>
<div style="background-color: red">
     <span>
           <a class="anchor">Text</a>
     </span>
</div>
Run Code Online (Sandbox Code Playgroud)

如果我点击中间锚点我想要这个:

<div>
     <span>
           <a class="anchor">Text</a>
     </span>
</div>
<div style="background-color: red">
     <span>
           <a class="anchor">Text</a>
     </span>
</div>
<div>
     <span>
           <a class="anchor">Text</a>
     </span>
</div>
Run Code Online (Sandbox Code Playgroud)

我想我明白为什么closest()将所有三个DIV都匹配为最接近点击锚点的DIV,因为它通常匹配DIV.

但是在使用时,parents()或者parent()它不像其他DIV那样清晰,不是点击锚点的父级.但是我也可以看到它在DOM中的那个级别再次与DIV再次匹配.虽然在匹配时似乎 …

jquery parents traversal parent closest

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

如何将 PhP 变量放入 img src 中?

我正在尝试将图像放入我的网站中,但我需要 srcphp变量,并且我收到控制台错误“找不到路径”,但图像应该在那里。

设置图像变量

<?php
    $rand = rand(1,2);
    $image = "imagePath";

    switch ($rand) {
        case 1:
            $image = "images/image1.jpg";
            break;
        case 2:
            $image = "images/image2.png";
            break;
        default:
            break;
    }
?>
Run Code Online (Sandbox Code Playgroud)

试图找回它

<img src="<?php $image ?>" />
Run Code Online (Sandbox Code Playgroud)

错误信息

file:///C:/Users/Leonardo/Desktop/Games/M/Site/%3C?php%20$image%20?%3E 无法加载资源:net::ERR_FILE_NOT_FOUND

如何在img的src属性$image内插入路径?

php

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

更改按钮:在css中激活

我怎么能改变按钮有border-radius:6px; 当我选择它时,通过激活标记.这是我的HTML代码,我也有CSS.当我让<button class:active 我只有活动按钮没有CSS风格

<div align="center">
     <label>Period selection</label>
     <button class="button: active" id="Day" style="height:25px; width:60px; margin: 4px 2px" type="submit" onclick="setImage('1');">Day</button>
     <button class="button: active" id="Week" style="height:25px; width:60px; margin: 4px 2px" type="submit" onclick="setImage('2');">Week</button>
     <button class="button: active" id="Month" style="height:25px; width:60px; margin: 4px 2px" type="submit" onclick="setImage('3');">Month</button>
</div>
Run Code Online (Sandbox Code Playgroud)
.ctButton,
.button,
body div.ui-dialog div.ui-dialog-buttonpane div.ui-dialog-buttonset button.ui-button,
.ui-dialog .ui-button, 
a.button,
#ctPageContent a.button,
#ctPageContent a.button:hover {
     background-color: #2B2B2B;
     border: 0px;
     display: inline-block;
     padding: 3px 10px 4px;
     color: #fff;
     text-decoration: none;
     -moz-border-radius: 6px;
     -webkit-border-radius: 6px;
     border-radius: 6px;
     -moz-box-shadow: 0 …
Run Code Online (Sandbox Code Playgroud)

html css

0
推荐指数
1
解决办法
851
查看次数

这个Javascript非常慢

我想要完成的事情:

我试图将abbr的标题分别更新为".Left"和".Right"类中的值.我提出了一个jQuery解决方案,但它在加载时间方面太贵了,我试图想出一个Javascript解决方案,但我被卡住了.我是JS的新手,所以我有很多东西可以学习DOM.

我给出的HTML重复了100次(相同的骨架).如何让我的代码更高效?此外,我得到一个"无法设置null属性标题"错误.

var ratedSection = document.getElementsByClassName('RatedSection');
var ratedQuest = document.getElementsByClassName('RatedQuest');
var selector = document.getElementsByClassName('Selector');

for (var i = 0; i < ratedSection.length; i++) { //loops through ratedsection
  var left = ratedSection[i].querySelector('.Left');
  var right = ratedSection[i].querySelector('.Right');

  left = left.innerHTML.replace(/<br>/g, " ");
  right = right.innerHTML.replace(/<br>/g, " ");

  for (var j = 0; j < ratedQuest.length; j++) {
    for (var k = 0; k < selector.length; k++) {
      var index = ratedQuest[j].querySelector('input').value;

      if (index == 1)
        selector[k].querySelector('abbr').title = left;

      else if (index …
Run Code Online (Sandbox Code Playgroud)

html javascript

0
推荐指数
1
解决办法
58
查看次数

如何在此导航栏中的徽标中垂直居中img?

JSFiddle在这里.

正如您在给定的SSCCE中看到的那样,徽标中的图像与其旁边的文本不完全对齐.我需要它<img>并且<span>完美地相邻,因此它们是垂直 - 中间对齐的,而不是共享相同的基线.

我有这个:

在此输入图像描述

我需要这个:

在此输入图像描述

那我该怎么做?

给人vertical-align:middle;.brand-logo.brand-logo > img或两者.brand-logo > img.brand-logo > span没有帮助.

添加类valign-wrappera.brand-logo或者div.nav-wrapper还没有帮助.(来源)

<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css" rel="stylesheet"/>


<nav class="black">
	<div class="nav-wrapper">

		<a class="brand-logo center brown-text text-lighten-4" href="#"><img alt="" src="https://s.w.org/about/images/logos/wordpress-logo-simplified-rgb.png" width="40px" height="40px" class="responsive-img" />
			<span>BRAND</span>
		</a>

	</div>
</nav>
Run Code Online (Sandbox Code Playgroud)

html css jquery materialize

0
推荐指数
1
解决办法
940
查看次数

文本在跨度内左对齐

我有一个段落拆分如下:

<a href="#" class="nostyle">
  <p>
    <span class="heading">Really long heading</span><br>
    <br>
    Lots of text that needs to be justified
  </p>
</a>
Run Code Online (Sandbox Code Playgroud)

该段落设置为text-align: justify,它需要保留在该位置。我想要的只是<span>text-align: left这样行之间就不会形成大间隙。我怎样才能做到这一点?

我想将其全部保留为一个段落,因为它是弹性项目的一部分,并且有一个<h2>and<p>意味着它不会全部很好地工作!

谢谢。

html css

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

First two divs on the left (one under the other) and the the last one on the right using Flexbox

I'm trying to place three divs using Flexbox.

I need to put the .site-title and .site-description divs on the left one under the other, and the .menu-toggle button on the right like below.

在此处输入图片说明

I tried with some variations of the following CSS code with no success.

.container {
  display: flex;
  justify-content: space-between;
}

.site-title {
  flex: 0 0 auto;
  align-self: flex-start;
}

.site-description {
  flex: 0 0 auto;
  align-self: flex-start;
}

.menu-toggle {
  flex: 0 0 auto;
  align-self: flex-end;
} …
Run Code Online (Sandbox Code Playgroud)

html css flexbox

0
推荐指数
1
解决办法
57
查看次数

标签 统计

html ×6

css ×5

jquery ×2

closest ×1

flexbox ×1

javascript ×1

materialize ×1

parent ×1

parents ×1

php ×1

traversal ×1