因此,如果某个类存在于其他地方的代码中,我只想应用特定的 CSS。我想知道这是否只能通过 css 实现,或者是否需要使用 Jquery 来实现。有人对此有什么想法吗?如果我需要使用 Jquery,你能举个例子说明它的样子吗?
正如您在我的代码中所看到的,我尝试做的是应用一个“margin-top何时li.active存在”。
显然我的 jsfiddle 不起作用:http://jsfiddle.net/zt40oa7d/
或者看下面的代码:
div.navbar {
background-color: #CCF;
}
ul.box {
margin: 0;
}
div.text {
background-color: #FFC;
padding: 10px;
}
div.page div.navbar ul.box li.active div.text {
margin-top: 100px;
}Run Code Online (Sandbox Code Playgroud)
<div class="page">
<div class="navbar">
<ul class="box">
<li class="active"><a href="#">Link 1</a>
</li>
</ul>
</div>
<div class="text">This the div that should go down due to the submenu ul</div>
</div>Run Code Online (Sandbox Code Playgroud)
我很擅长使用Excel作为网页抓取工具,但我发现这篇非常有趣的文章解释了如何使用Excel VBA从网站上抓取某些标签.我有下面的代码工作正常,但它只从<p>它找到的第一个标签获取内容:
Sub get_title_header()
Dim wb As Object
Dim doc As Object
Dim sURL As String
Dim lastrow As Long
lastrow = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To lastrow
Set wb = CreateObject("internetExplorer.Application")
sURL = Cells(i, 1)
wb.navigate sURL
wb.Visible = True
While wb.Busy
DoEvents
Wend
'HTML document
Set doc = wb.document
Cells(i, 2) = doc.title
On Error GoTo err_clear
Cells(i, 3) = doc.GetElementsByTagName("p")(0).innerText
err_clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If …Run Code Online (Sandbox Code Playgroud)