javascript - CSS apply property to just the first created element -
i'm appending buttons div detailed here - append button div using javascript
every button gets added through addbtns();
function call. hence, css applied gets applied every button gets appended div.
the problem have want buttons aligned @ bottom right hand corner of div. tried setting top-margin
& left-margin
properties. left-margin
, problem have margin gets applied every button & hence spacing between buttons changes.
i'd left-margin
applied first button gets created in div in case button labelled 'a'
could please request achieve i'm after?
you can achieve pure css:
input:first-child { margin-left: 30%; }
it work dynamically created elements well. had add width:50%;
appendtome
because did not have width originally. additionally, added margin-left:30%
instead of 300%
because goes outside of boundaries.
check out on codepen
Comments
Post a Comment