import streamlit as st
button_col, other_col= st.columns([1,3])
st.markdown("""
<style>
[data-testid=column]:nth-of-type(1) [data-testid=stVerticalBlock]{
gap: 0rem;
}
</style>
""",unsafe_allow_html=True)
with button_col:
"*Modified gap:*"
st.checkbox("text")
st.checkbox("text1")
st.checkbox("text2")
with other_col:
"*Unmodified gap:*"
st.checkbox("text4")
st.checkbox("text5")
st.checkbox("text6")
st.markdown("## A header")
st.markdown("🪄 This is a repeated sentence"*100)
Sure, so this changes the gap between elements in the first column to 0rem. The logic behind it is that it looks for all the column elements in the page ([data-testid=column]), then picks the first one (:nth-of-type() selector), and then it selects the [data-testid=stVerticalBlock] element, which is the one that has the gap property. Notice that gap: 0rem does not apply to the checkboxes but to everything placed in that first column, so it should apply for selectboxes or whatever you put in there.
Here is a better explanation on how to find those tags and target particular css properties on an page:
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.