I am trying to make three buttons use the full width of a column.
The grid is 3 for the buttons and 9 for other components.
Here's a visual. So basically the buttons should also occupy the space that's marked with red, they should just use the whole column of 3.
Here's App.js where I imported the component:
<div className="container-full padding-0" style={{overflow:'hidden', overflowY:'hidden'}}>
<div className="row">
<div className="col-sm-3" style={{borderRight:"1px solid #000"}}>
<div className="row no-gutters mt-auto">
<div className="col-sm-3">
<COMPONENT1/>
</div>
<div className="col-sm-9">
<COMPONENT2/>
</div>
</div>
<COMPONENT3 store={store} style={{overflow:'hidden'}}/>
<COMPONENT4/>
<BUTTONS/> --------------------------> Here are the buttons
</div>
<div className="col-sm-9" style={{paddingRight: 0, paddingLeft: 0}}>
<COMPONENT6 = {store} style={{overflow:'hidden'}}/>
<br/>
<COMPONENT7/>
<COMPONENT8 store={store} clicked={this.clicked}/>
</div>
</div>
</div>
And buttons component:
<div className="row no-gutters mt-auto" style={{paddingTop:10}}>
<div className="col-sm-4">
<Button variant="raised" style={buttonStyle}>A</Button>
</div>
<div className="col-sm-4">
<Button variant="raised" style={buttonStyle}>B</Button>
</div>
<div className="col-sm-4">
<Button variant="raised" style={buttonStyle}>C</Button>
</div>
</div>
And the css for the buttons:
const buttonStyle = {
fontSize: 20,
textAlign: 'center',
display:'inline-block',
width:'100%',
height:100
}
EDIT: Here's a quick pic of the UI
Can you please try the following method:
Give below css rules to row no-gutters mt-auto:
style={{ display: 'flex', flex: 1, flexDirection: 'row' }}
It will work for sure !
Thanks
Related
The text should be in white badge with text center . I use gatsby StaticImages by the way....
Code..
<div class="row mx-4" style={{ position:'relative' }}>
<StaticImage style={{ position:'absolute', filter: 'brightness(100%)' }} src="../images/scrollg.png" alt="tatil" placeholder="tracedSVG" />
<div className="d-flex justify-content-end pt-4 pe-4" >
<StaticImage src="../images/badge.svg" alt="tatil" placeholder="tracedSVG" />
<div style={{ position:'absolute'}}> <p className="text-center">200€’dan başlayan fiyatlarla</p></div>
</div>
<div className="row mx-5 scrollg" style={{ position:'absolute' , height:'400px'}}>
<div className="col-12 my-auto">
<h4 className="fw-bold text-white">Roma’yı Keşfetme Mevsimi</h4><br />
<p className="col-lg-5 col-md-5 col-sm-12 scrollg">Haydi, siz de Tatilbudur’un uygun fiyatlı yurt dışı turlarını incelemeye başlayın, yurt dışında daha fazla yeni yerler keşfetmenin keyfine varın!</p>
<button class=" px-3 py-1 scrollg-button rounded-pill "> Fırsatları Gör</button>
</div>
</div>
</div>
The text here needs to be positioned absolutely and relative to the parent div element within which the text and the image are. So you'll have to add position-relative class to the parent.
To center the text vertically, you can add equal distance on the top and bottom.
To make sure the text is within the white badge, you can add some fixed width to th text div.
<div className="d-flex justify-content-end pt-4 pe-4 position-relative">
<StaticImage src="../images/badge.svg" alt="tatil" placeholder="tracedSVG" />
// I've added 100px width as an example.
<div style={{ position:'absolute', top: '25%', bottom: '25%', width: '100px'}}>
<p className="text-center">200€’dan başlayan fiyatlarla</p>
</div>
</div>
Why does the Bootstrap container component size differently than a regular HTML Bootstrap, not sure if I am missing a prop or not?
This is what I get the output I get for both:
(the white space in the sides are from the container margin)
React code:
<Container>
<Row className="row">
<Col className="col-lg-3 col-md-4">
<div
style={{ width: "100%", height: "100vh", backgroundColor: "blue" }}
></div>
</Col>
<div className="col-lg-9 col-md-8 tab-container">
<div
style={{ width: "100%", height: "100vh", backgroundColor: "red" }}
></div>
</div>
</Row>
</Container>
Regular HTML code:
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-4">
<div style="width: 100%; height: 100vh; background-color: blue"></div>
</div>
<div class="col-lg-9 col-md-8">
<div style="width: 100%; height: 100vh; background-color: red"></div>
</div>
</div>
</div>
Can someone help with the correct styling/fix for the React version to match the regular one please?
I am working with a react component that produces nested divs. I'd like to style force the divs to be on the same line but can only declare styles on the outer container div. Is there a way to achieve this without styling the inner divs? If only I can pass style to the "hello" div.
Currently:
hello
secondLine thirdLine
Desired:
hello secondLine thirdLine
<div style={{ textAlign: "left", whiteSpace: "nowrap" }}>
<div style={{ display: "inline" }}>
<div>hello</div>
</div>
{` `}
<div style={{ display: "inline" }}> secondDiv </div>
<div style={{ display: "inline" }}> thirdDiv </div>
</div>
make the outer div display: 'flex'
<div style={{ textAlign: "left", whiteSpace: "nowrap",display:"flex" }}>
<div style={{ display: "inline" }}>
<div>hello</div>
</div>
{ }
<div style={{ display: "inline" }}> secondDiv </div>
<div style={{ display: "inline" }}> thirdDiv </div>
</div>
For more reference :details
if you have access and can change the HTML change the inner <div> to <span> or any inline element, the parent div have display:inline and inner div will take full width ignoring parent having inline display, because the inner div have default display block:
<div style="textAlign:left, whiteSpace:nowrap">
<div style="display:inline">
<span style="display:inline">hello</span>
</div>
<div style="display:inline"> secondDiv </div>
<div style="display:inline"> thirdDiv </div>
</div>
for your jsx code it should be like:
<div style={{ textAlign: "left", whiteSpace: "nowrap" }}>
<div style={{ display: "inline" }}>
<span>hello</span>
</div>
{` `}
<div style={{ display: "inline" }}> secondDiv </div>
<div style={{ display: "inline" }}> thirdDiv </div>
</div>
I need to add a label to the rc-slider in the same row and i used bootstrap grid but the label and the slider appears in two rows.
<div className="row">
<div className="col">
Label:
</div>
<div className="col">
<Slider value={this.props.sample}
onChange={this.onSliderChange}
onAfterChange={this.onAfterChange}
defaultValue={13}
/>
</div>
You need to place the row inside a div with the container class.
<div class="container">
<div className="row">
<div className="col">
Label:
</div>
<div className="col">
<Slider value={this.props.sample} onChange={this.onSliderChange} onAfterChange={this.onAfterChange} defaultValue={13} />
</div>
</div>
</div>
More info in the grid documentation: https://getbootstrap.com/docs/4.1/layout/grid/
You must be having the issue with including the bootstrap, check in your code is bootstrap is loading in your devtools network tab. After confirming that, change the className of the columns class in bootstrap. like below. This should work for you.
<div className="row">
<div className="col-lg-1">
Label
</div>
<div className="col-lg-11">
<Slider
value={10}
onChange={this.onSliderChange}
onAfterChange={this.onAfterChange}
/>
</div>
</div>
I want - box to come exactly below + box as shown in the attached image
I have tried this code given below but does not work. Can someone tell me what changes I need to make in the css. This is part of reactjs application.
<div style={{width:"20%",float:"left"}}>
<input type="text" style={{width:"50px",height:"60px",marginLeft:"20px",marginTop:"20px",float:"left"}}/>
<div style={{fontSize:"25px",fontWeight:"bold", width:"30px",float:"left",border:"1px solid #eee", marginTop:"20px",marginLeft:"5px",textAlign:"center"}}><a href="#" style={{textDecoration:"none"}}>+</a></div>
<div style={{fontSize:"25px",fontWeight:"bold", width:"30px",float:"left",border:"1px solid #eee", marginTop:"20px",marginLeft:"5px",textAlign:"center"}}><a href="#" style={{textDecoration:"none"}}>-</a></div>
</div>
Wrap your +/- boxes in a div and use display: flex with flex-direction: column styles on the wrapper div like
<div style={{width:"20%",float:"left"}}>
<input type="text" style={{width:"50px",height:"60px",marginLeft:"20px",marginTop:"20px",float:"left"}}/>
<div style={{display: 'flex', flexDirection: 'column' }}>
<div style={{fontSize:"25px",fontWeight:"bold", width:"30px",float:"left",border:"1px solid #eee", marginTop:"20px",marginLeft:"5px",textAlign:"center"}}><a href="#" style={{textDecoration:"none"}}>+</a></div>
<div style={{fontSize:"25px",fontWeight:"bold", width:"30px",float:"left",border:"1px solid #eee", marginTop:"20px",marginLeft:"5px",textAlign:"center"}}><a href="#" style={{textDecoration:"none"}}>-</a></div>
</div>
</div>
Wrapp em in div with flex
<div style={{ display: 'flex', flexDirection: 'column' }}>
</div>