如何在一个CSS选择器中访问两个ID [英] How to access two Ids in one css selector

查看:280
本文介绍了如何在一个CSS选择器中访问两个ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有div有三个按钮,

I have div which has three buttons as,

<div id="buttons">
    <input id="preview" class="ButtonStyle" type="submit" value="Preview" name="preview">
    <input id="add" class="ButtonStyle" type="submit" value="Save" name="add">
    <input id="Cancel" class="ButtonStyle" type="submit" value="Cancel" name="Cancel">
</div>

我设置了它的样式。我想要添加和取消按钮有他们的左边距:5px;现在我以这种方式做了,

I set its style. I want that both add and cancel button have their left-margin: 5px; Right now I am doing it in this manner,

#outboxmidpg #buttons input[type="submit"]{
    font-weight: bold;
    width: 70px;
}

#outboxmidpg #buttons input[id="Cancel"] {
    margin-left: 5px;
}

#outboxmidpg #buttons input[id="add"] {
    margin-left: 5px;
}

我想在一行中做。我试过这个,但它没有工作,它删除了取消按钮边距太。

I want to do it in one line. I tried this, but it didn't work and it removes the cancel button margin too.

#outboxmidpg #buttons input[id="Cancel"] input[id="add"] {
    margin-left: 5px;
}

还有,我可以在一行中实现风格吗?

Is there anyway that I can achieve the style in one line?

感谢

推荐答案

#buttons input:nth-child(2), #buttons input:nth-child(3){
    margin-left:5px;
}

这对你有用吗?

或简单:

#Cancel, #add{
    margin-left:5px;
}

使用您将启动一个完整的新CSS选择器并将其组合。

With , seperation you start a complete new CSS Selector and combine them.

这篇关于如何在一个CSS选择器中访问两个ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆