Frost
Frost
KPCKevin Powell - Community
Created by Frost on 10/27/2024 in #front-end
How to Set Width of a New Container Element to Match an Existing Element's Width in JavaScript?
thanks again, i'll play around with this
39 replies
KPCKevin Powell - Community
Created by Frost on 10/27/2024 in #front-end
How to Set Width of a New Container Element to Match an Existing Element's Width in JavaScript?
if only there is similar method to getComputedStyle, but instead of returning the computed style value of an element, it returns the value that was set for the property, If no value was set, it would return the default value of that property. For example:
getActualStyleValue(element).getPropertyValue('width');
getActualStyleValue(element).getPropertyValue('width');
im still searching for a way similar to this but still no luck
39 replies
KPCKevin Powell - Community
Created by Frost on 10/27/2024 in #front-end
How to Set Width of a New Container Element to Match an Existing Element's Width in JavaScript?
Thank you for your feedback really appreciate it, but, there are several problems with this function. First, there are specificity issues it might return the first match, which may not be the most specific style applied to the element. Also, if an element has inline styles, the function does not acccount for those, as well if the application has a lot of stylesheets, iterating through all of them may not be efficient. I also want the selector matching to be more configurable, as some of the users utilize combinators or attribute selectors for their elements. im trying to use this in a javascript library that im writing so i want to find a soluion that is more flexible, if there is no other way im just gonna set a default width to the new containerElement or just allow them to set a specific width to it
newContainerElement(element,{ width:'auto' } /* if not provided use the default value*/)
newContainerElement(element,{ width:'auto' } /* if not provided use the default value*/)
39 replies
KPCKevin Powell - Community
Created by Frost on 10/27/2024 in #front-end
How to Set Width of a New Container Element to Match an Existing Element's Width in JavaScript?
The HTMLElement.offsetWidth read-only property returns the layout width of an element as an integer.
The HTMLElement.offsetWidth read-only property returns the layout width of an element as an integer.
I also want to get a value of auto if there's no specific width set to an element, and also for max-content, min-content, fit-content etc..
39 replies
KPCKevin Powell - Community
Created by Frost on 12/20/2023 in #front-end
How to select an element that doesn't have a child or contains a particular element
it's working now, thanks!
8 replies
KPCKevin Powell - Community
Created by Frost on 12/20/2023 in #front-end
How to select an element that doesn't have a child or contains a particular element
<style>
.category-container:has(>:not(.category)){
background-color:red;
}
</style>

<div class="category-container">
<div class="category"><span>test</span></div>
<div><span>test</span></div>
</div>
<style>
.category-container:has(>:not(.category)){
background-color:red;
}
</style>

<div class="category-container">
<div class="category"><span>test</span></div>
<div><span>test</span></div>
</div>
it is only working when the container element only contains a one div but when i add another div it's not matching the container element.
8 replies
KPCKevin Powell - Community
Created by Frost on 12/20/2023 in #front-end
How to select an element that doesn't have a child or contains a particular element
it's still not working i don't know why
8 replies