的方式,W3Schools的短语吧,他们的声音一样.
div + p
选择<p>紧跟<div>元素后面的所有元素
div ~ p
选择<p>元素前面的每个<div>元素
如果<p>元素紧跟在<div>元素之后,那是不是意味着<p>元素前面有<div>元素?
无论如何,我正在寻找一个选择器,我可以选择一个位于给定元素之前的元素.
客户端正在使用内容管理系统将文本注入到表示按钮的2个div中.我希望按钮的高度相等.问题是:
CSS,那么只有在客户端没有输入太多文本时才有效.CSS,那么只有当客户端输入相同数量的文本行时才能使用.所以我认为JQuery会在这个问题上拯救.你能帮我弄清楚使用哪些功能吗?
问题的大纲是:
<div id="button1">
<p>Here's some text that the client will control.</p>
</div>
<div id="button2">
<p>Here's some more text that the client will control</p>
</div>
<script type="text/javascript">
/* Here will go some JS to make button1 and button2 the height of whichever one is taller when the page has loaded the client's text that the CMS injected */
</script>
Run Code Online (Sandbox Code Playgroud)