Search code examples
javascriptloopsgrid-layout

Fixed Well Size in Bootstrap


I have a loop of text displaying on a page, with a button that cycles the loop. Everytime I click the button, the well changes sizes, as the text is different lengths, is there a way that I can set the well size so that with each click it stays fixed but at the same time still responsive?

        <div class ="col-md-6">
            <p id="quote">Delighted with my experience. Easy and comfortable. I have the utmost confidence in Scott and trust him to help me find the right vehicle for my self, family members and friends I have referred. I just purchased my 4th car from him. </p><button type="button" class="btn btn-success btn-lg" onclick = "cycle()">&gt</button>                
        </div>

function cycle() {
var randomNumber = Math.floor(Math.random() * (testimonials.length))
document.getElementById('quote').innerHTML = textimonals[randomNumber];
}
var testimonials = ["ex.", "ex.", "ex."]

Solution

  • You can use min-height so it would stay at minimum height and be responsive as well.

    function cycle() {
       var randomNumber = Math.floor(Math.random() *    (testimonials.length))
       document.getElementById('quote').innerHTML = testimonials[randomNumber];
    }
    
    var testimonials = ["ex.", "ex.", "ex.", "Delighted with my experience. Easy and comfortable. I have the utmost confidence in Scott and trust him to help me find the right vehicle for my self, family members and friends I have referred. I just purchased my 4th car from him. Delighted with my experience. Easy and comfortable. I have the utmost confidence in Scott and trust him to help me find the right vehicle for my self, family members and friends I have referred. I just purchased my 4th car from him."];
    #quote {
      min-height: 50px;
    }
    <div class ="col-md-6">
                <p id="quote">Delighted with my experience. Easy and comfortable. I have the utmost confidence in Scott and trust him to help me find the right vehicle for my self, family members and friends I have referred. I just purchased my 4th car from him. </p><button type="button" class="btn btn-success btn-lg" onclick = "cycle()">&gt</button>                
    </div>