问题
I am unable to get the width and heigh properties to work for my custom tags please see code below: CSS
x-slider
{
width: 1000px;
height: 300px;
border: 1px black solid;
background-color: #0000ff;
}
HTML
<body><x-slider id="CoolPics" page="home"></x-slider></body>
Javascript
var x = document.registerElement('x-slider', {
prototype: Object.create(HTMLDivElement.prototype), extends: 'div'
});
I added the Extension of the DIV object to see if that would allow me to specify heigh since some tags do not allow for height. Is it only certain css properties that work with custom tags? Both the border and background color show up, I have tried changing over to both min and max height as well. Please limit response to the question and not the subjective argument of whether you should use custom tags, It made it significantly harder to search for answer for this with every post about custom tags overloaded with those kinda of responses.
回答1:
Add display: block
or display: inline-block
to x-slider
.
来源:https://stackoverflow.com/questions/24854775/css-width-with-custom-tags