i feel like if we had an option in css to get the width of an element
example.css
:root{
--btnWidth: getWidth('#sourceEl');
and / or
--btnWidth: getWidth('.sourceEl');
}
.targetEl{
width: var(--btnWidth);
}
For further actions, you may consider blocking this person and/or reporting abuse
Miguel -
T Sudhish Nair -
Biz Maven -
waelhabbal -
Top comments (4)
I think that because you can just set both elements to the same width is the reason this doesn't need to exist?
I also feel like being able to do this would potentially introduce issues - consider this type of setup:
Should the element's width be a snapshot when the page loads? Should it dynamically change? Will every browser implement the decision the same way?
You can get/set the width via JS if you wanted - but I suspect this will lead to a lot more headaches down the road, especially if you're trying to implement a mobile and desktop layout.
But the best way to find out for sure is to give it a try! π§ͺ
A shared class or css variable should do just fine for this case.
Well.. JavaScript it is :D
ya I know we can give same width using bootstrap classes. What dou you guys think about this