Styling an Input Button using “Sliding Doors”

前端 未结 3 1554
忘掉有多难
忘掉有多难 2021-01-25 07:14

I have a webpage that is using third-party HTML that I cannot change. I can however edit the CSS style sheet. I have a \"sliding-doors\" style button that I want to swap for the

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-25 07:43

    You need two elements to do nested background joining (aka sliding doors): an outer (background) one and an inner (foreground, containing the end-piece of the background image). If you only have a standalone you're stuck.

    If you can find a way to select the

    you mentioned, you could use that as the outer element, with the button (with its natural background colour removed) as the inner. You would have to make sure the outer div was the same width/height as the inner , though, perhaps by floating it left (to activate the ‘shrink-to-fit’ behaviour that comes with floats). You would also need to account for the top margin on the button, and any padding on it.

    #something div {
        float: left;
        background: transparent url('http://mydomain.com/projects/buttons/sliding-doors/images/bg_button_oval_a.gif') no-repeat 0 10px;
    }
    #something div input {
        background: transparent url('http://mydomain.com/projects/buttons/sliding-doors/images/bg_button_oval_span.gif') no-repeat;
        border: none;
        padding: 0;
    }
    

    However, as the button in question has a fixed-pixel on-page size, you don't really need to use nested backgrounds at all. You can just make one background of the right dimensons for the button.

提交回复
热议问题