In the first column, is it possible to have a label instead a button? Visually I want the same as a label or a button, but I don't wanna it to be clickable. The text is getting out too. And I was trying to make the button smaller but it isn't accepting width.
FIDDLE
<div>
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><span>AA</span></h4>
</div>
<div class="modal-body">
<form role="form" class="container-fluid">
<div class="form-group col-md-6">
<label>Text</label>
<div class="btn-group btn-group-justified">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla laoreet eget neque
BUTTON
</div>
</div>
<div class="col-md-6">
<label>Text 2</label>
<div class="btn-group btn-group-justified">
BUTTON 2
</div>
</div>
</form>
</div>
<div class="modal-footer">
<a class="btn btn-default" href="#">Cancelar</a>
</div>
</div>
</div>
</div>
Visually I want the same as a label or a button, but I don't wanna it
to be clickable.
The best way would be to add the disabled attribute on the element. Then cancel out the reduced opacity using your own class
HTML
<a href="#" class="btn btn-warning myClass btn-sm" disabled>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla laoreet eget neque</a>
CSS
.myClass[disabled] {
opacity: 1;
}
The text is getting out too.
Just add this to the above CSS ruleset
white-space: normal;
And I was trying to make the button smaller but it isn't accepting
width.
The display for btn in the btn-group-justified class is table-cell and the width is set to 1% for all columns. So you have to set your width keeping in mind that 1% is the default.
For example the following makes it 25% for a 2 column button group
width: 0.5%;
The complete CSS would be
.myClass[disabled] {
opacity: 1;
white-space: normal;
width: 0.5%;
}
Fiddle - http://jsfiddle.net/wr78t8ug/
Related
I'm trying to upgrade my site from Bootstrap 3 to Bootstrap 4. When I changed to Bootstrap 4, now a URL that is inside the modal-body exceeds the width of the modal. As far as I can tell the syntax of the modal is correct for Bootstrap 4, so I'm not sure why the modal width isn't stretching to fit the URL like it did in Bootstrap 3.
Here is a screenshot with the URL circled in yellow: URL too wide
Here is the code:
<?php
echo "<div class='modal fade' id='$p->fldHref' tabindex='-1' role='dialog' aria-labelledby='$p->fldModalLabel'>
<div class='modal-dialog' role='document'>
<div class='modal-content'>
<div class='modal-header'>
<h3 class='modal-title' id='$p->fldModalLabel'>$p->fldModalTitle</h3>
<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button>
</div>
<div class='modal-body'>
<p>".html_entity_decode($p->fldModalBody)."</p>
</div>
<div class='modal-footer'>
<button type='button' class='btn btn-default btn-sm' data-dismiss='modal'>Close</button>
</div>
</div>
</div>
</div>"
?>
use whitespace css property. here is an example: https://www.w3schools.com/cssref/pr_text_white-space.asp
here is playground: https://www.w3schools.com/cssref/playit.asp?filename=playcss_white-space&preval=pre
Check what is specified on your code with inspect element and try with whitespace -> It should solve
Use CSS word-break: break-word; for .modal-body and to do that add another class with it (.modal-body) or better if you add another div inside and use word-break: break-word; in that (like the snippet below), whenever you do word-break: break-word; could be the solution-
.modal-body-content {
word-break: break-word
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Lorem ipsum dolor sit amet consectetur adipisicing elit. Asperiores, quasi quidem magnam?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="modal-body-content">
<p>Lorem ipsum, dolor, sit amet consectetur adipisicing elit. Quo amet, ullam aliquam!</p>
<p>Excepturi magnam, rerum explicabo dolorum vel quo, qui! Necessitatibus non nulla, nostrum.</p>
https://www.google.com/search?q=pgbjr+oijfgboiwn+ogmn+wigj+oiwm+igjbioijeaifo+i+ijerijkoferfgjo&rlz=1C1CHBD_enBD924BD924&oq=pgbjr+oijfgboiwn+ogmn+wigj+oiwm+igjbioijeaifo+i+ijerijkoferfgjo&aqs=chrome..69i57.4620j0j7&sourceid=chrome&ie=UTF-8
<p>Ipsa cumque dignissimos odio optio deleniti ab, iste consequuntur rerum, obcaecati repellat?</p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
I have just started learning Bootstrap and one month into CSS. I am coding a page and I feel I have a poor understanding of pixels and responsive design.
So I have three images (.demo) in a section. The first image (.png) is 668x522 px and the other two (.jpeg) are 548x445 px. I am using col-md-4 for each image. I see that the tallest image ends up being shorter than the other two. You can see my page here. Notice how the leftmost image is shorter than the other two even though it has a greater height pixel-wise. My questions are
Why is the height shorter for the first image ? (I expected it to be tallest among the three). When I measure the other images in Chrome I see that their image height is 345 x 280px .How and who determines the rendered dimensions ?
I want all three to have the same height. I did img.demo {height :280px ; } and all images were lined up nicely but I understand this is not responsive. I tried img.demo { height :73% } (width of parent container col-md-4 is 380 px so height of 73% for img.demo should give 280px height to it. But settings a height in % to img.demo is not doing anything to it. Why is that ?
What would be the responsive way to have all images the same height ?
HTML :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Starter Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html"><strong>GemniPro</strong></a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<section>
<div class="jumbotron">
<div class = "container">
<div class = "row">
<div class = "col-md-6">
<h1>Capture <strong>Life</strong></h1>
<p>A fun and easy way to capture and share the moments you live for</p>
<img class= "app-btn" src="img/icon_app_store.png">
<img class= "app-btn" src="img/icon_google_play.png">
</div>
<div class = "col-md-6">
<img class ="showcase" src = "img/site_phone.png" >
</div>
</div>
</div>
</div>
</section>
<section id = "middle">
<div class = "row">
<div class ="container">
<div class = "col-md-4 ">
<img src = "img/demo1.png" class="demo" >
<h3> Lorem Ipsum</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lobortis tempus varius. Sed porttitor ex id lectus interdum tristique.</p>
</div>
<div class = "col-md-4 ">
<img src = "img/demo2.jpg" class="demo">
<h3> Lorem Ipsum</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lobortis tempus varius. Sed porttitor ex id lectus interdum tristique.</p>
</div>
<div class = "col-md-4 demo">
<img src = "img/demo3.jpg" class="demo">
<h3> Lorem Ipsum</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lobortis tempus varius. Sed porttitor ex id lectus interdum tristique.</p>
</div>
</div>
</div>
</section>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/main.js"></script>
</body>
</html>
CSS :
body {
margin-top: 50px;
}
strong {
color:aqua ;
}
section#middle {
padding:40px 0 40px 0;
}
.jumbotron {
color :#fff;
background: url("../img/site_showcase_bg.jpg");
height:500px;
overflow:hidden;
}
.jumbotron img.app-btn {
height : 60px;
width:40%
}
.jumbotron h1 {
margin-top:125px;
}
.jumbotron p {
margin-bottom:50px;
}
.jumbotron img.showcase {
width:75%;
}
#middle img.demo {
width:100%;
height:73%;
border:solid 1px #ccc;
}
Images maintain their aspect ratio if you do not apply any width or height. In case you apply both of them in such a way that the aspect ratio is greater than the original, the image gets distorted.
The height to width ratio of the first image is greater than the other 2 images which are equal in height and width. The more width will be, the less the height will be.
The percentage height is calculated with reference to the parent height. Since, the enclosing container of .demo does not have a height, defining a height in percentage has no effect.
Either take the images of the same size. Or
.demo
max-width: 100%;
height: 280px;
border: solid 1px #ccc;
Or
.demo
max-width: 100%;
There is not much difference in the height of all 3 images, so its safe to remove the border altogether. ;)
The first image is a little bit smaller because its aspect ratio is different from the other two:
The first image original size is: 668x552 | aspect ratio = 1.210
The other two are: 548x445 | aspect ratio = 1.231
They need to have the same aspect ratio or you can put them inside a div and display them as background-size: contain
Im using bootstrap 4.0.0-beta.2 and I have a css problem.
I want following layout
This is the html:
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<div id="task" class="container">
<div class="row">
<div class="col-12">
<div class="card card-shadow">
<div class="card-header accent-color">
FOOOOOOOO
</div>
<div class="card-body">
<h4 class="card-title">BAAAR</h4>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum id consectetur lorem, quis mattis orci.</p>
Go somewhere
</div>
</div>
</div>
<div class="col-12">
<div class="card card-shadow" id="paint">
<div class="card-header accent-color">
paint
</div>
<div class="card-body">
<app-paint></app-paint>
</div>
</div>
</div>
</div>
</div>
And what im trying to create is a layout of cards.
I want the first card to stay within the col-12 width and adapt the hight after content. And then I want the second div to always end at bottom of page. No margin between. So I tried to add position:fixed, bottom:0 and height:100% but then the width get wierd and it cant handle resize of the page. So How can I force the second div to end at page bottom?
You may use height and margins.
Boostrap class: .h-100 sets height:100% , but parent need an height where % can be calculated from (css added for html & body)
margin-top:auto and bottom 0 will send the second element at the bottom. boostrp classes used : mt-auto mb-0
html,
body {
height: 100%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet" />
<div id="task" class="container h-100"><!-- class added -->
<div class="row h-100"><!-- class added -->
<div class="col-12">
<div class="card card-shadow">
<div class="card-header accent-color">
FOOOOOOOO
</div>
<div class="card-body">
<h4 class="card-title">BAAAR</h4>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum id consectetur lorem, quis mattis orci.</p>
Go somewhere
</div>
</div>
</div>
<div class="col-12 mb-0 mt-auto"><!-- class added -->
<div class="card card-shadow" id="paint">
<div class="card-header accent-color">
paint
</div>
<div class="card-body">
<app-paint>app-paint</app-paint>
</div>
</div>
</div>
</div>
</div>
or do you need the second div to expand ?
html,
body {
height: 100%;
}
.custom-flex {
flex: 1;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet" />
<div id="task" class="container flex-column h-100">
<!-- class added -->
<div class="d-flex flex-column h-100">
<div class="">
<div class="card card-shadow">
<div class="card-header accent-color">
FOOOOOOOO
</div>
<div class="card-body">
<h4 class="card-title">BAAAR</h4>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum id consectetur lorem, quis mattis orci.</p>
Go somewhere
</div>
</div>
</div>
<div class="d-flex flex-column custom-flex">
<div class="card card-shadow custom-flex" id="paint">
<div class="card-header accent-color">
paint
</div>
<div class="card-body">
<app-paint>app-paint</app-paint>
</div>
</div>
</div>
</div>
</div>
I think the answer of this question would be to change the css of the card. If you are looking for to increase or decrease the space between the cards from top or from bottom you should change the css like so:
In your case for card shadow it would be
.d-flex [class*='card-shadow'] {
margin-top: 2.5em;
margin-bottm: 2.5em;
}
Use your own unit for css calculation em, px or whatever suit you.
I am trying to create a layout using Flexbox where I have elements which consist of 3 other internal elements. The parent item element contains 3 divs: image, button, text. The issue is that my items will not always contain images or text that is the same height as the others. The button is the one thing that will have a consistent height. I am trying to figure out if it's possible to have each of my image divs be the same height as the tallest one and same for the text divs. I would also like the images to be vertically aligned to the bottom, so if one element has a shorter image, the white space to make the element the same height will go above the image like this:
And here is what I have so far:
.container {
display:flex;
flex-wrap:wrap;
flex-flow:row wrap;
justify-content:center;
}
.item {
max-width:200px;
margin:0 20px;
}
<div class="container">
<div class="item">
<div class="image">
<img src="http://placehold.it/150x300" />
</div>
<div class="button">
<button>Click Me</button>
</div>
<div class="text">
<p>consectetur adipiscing elit.</p>
</div>
</div>
<div class="item">
<div class="image">
<img src="http://placehold.it/150x200" />
</div>
<div class="button">
<button>Click Me</button>
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
<div class="item">
<div class="image">
<img src="http://placehold.it/150x250" />
</div>
<div class="button">
<button>Click Me</button>
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet</p>
</div>
</div>
<div class="item">
<div class="image">
<img src="http://placehold.it/150x270" />
</div>
<div class="button">
<button>Click Me</button>
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
</div>
I know that I could do this using Javascript to loop through each item to get the tallest and change the CSS of all others, but I'd like to use only CSS if possible. I also know that I could just set the height of the image container to the height of the tallest image, but these images are going to be dynamic and there are going to be a lot of them, so I'd rather have a solution that doesn't require hardcoding values.
Flexing the .item class and adding justify-content: flex-end; would provide the majority of the affect, but as far as I know you'd have to set a specific height on at least one of the items if you want two elements to be aligned the same across flexbox. Happy to be proven wrong though.
You could alternatively use margin-top: auto on the first child to push any unused space to the top and everything else down.
.container {
display:flex;
flex-wrap:wrap;
flex-flow:row wrap;
justify-content:center;
}
.item {
max-width:200px;
margin:0 20px;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
.text {
height: 36px; /* magic number */
}
<div class="container">
<div class="item">
<div class="image">
<img src="http://placehold.it/150x300" />
</div>
<div class="button">
<button>Click Me</button>
</div>
<div class="text">
<p>consectetur adipiscing elit.</p>
</div>
</div>
<div class="item">
<div class="image">
<img src="http://placehold.it/150x200" />
</div>
<div class="button">
<button>Click Me</button>
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
<div class="item">
<div class="image">
<img src="http://placehold.it/150x250" />
</div>
<div class="button">
<button>Click Me</button>
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet</p>
</div>
</div>
<div class="item">
<div class="image">
<img src="http://placehold.it/150x270" />
</div>
<div class="button">
<button>Click Me</button>
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
</div>
Using Bootstrap 4 alpha 6, I want to show a testimonial, comprising:
On the left: person photo
On the right: quote, name and company logo (left-aligned)
That is at tablet and desktop width.
But, when the window width shrinks, I want to stack the set, so that the image is on top of the text set, and each part becomes center-aligned.
Currently, this is my code...
<!-- testimonial -->
<div class="container-fluid cxt-padded bg-faded">
<div class="container">
<div class="media">
<img class="d-flex mr-4 rounded-circle" src="http://placehold.it/150x150" width="150" alt="Generic placeholder image">
<div class="media-body">
<p class="lead">"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius venenatis neque, id commodo magna fermentum id." link</i></p>
<h2 class="mt-0">Joe Smith</h2>
<img src="http://placehold.it/150x40" class="img-fluid" width="150">
</div>
</div>
</div>
</div>
This successfully produces the following outcome at desktop width...
However, when shrunk, the arrangement looks like this...
Instead, I would like the image to go on top, rather than be wrapped, and preferably be centered. The text below should preferably be centered.
That code is the media object.
I have also tried using two columns to accomplish this - one of width 2, the other of 10...
<!-- testimonial -->
<div class="container-fluid cxt-padded bg-faded">
<div class="container">
<div class="row">
<div class="col-md-2 text-center">
<img class="rounded-circle" src="http://placehold.it/150x150" width="150" alt="Generic placeholder image">
</div>
<div class="col-md-10 text-center">
<p class="lead">"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius venenatis neque, id commodo magna fermentum id." <i class="material-icons md-inverse pmd-sm">link</i></p>
<h2 class="mt-0">Joe Smith</h2>
<img src="http://placehold.it/150x40" class="img-fluid" width="150">
</div>
</div>
</div>
</div>
... This successfully produces the right-looking result at mobile width...
... However,
a) I'm not sure whether this mark-up is correct, and
b) This means the text is centered even at desktop width, which is inappropriate...
I'm getting confused about the right approach, whether/when I should use img-fluid versus a fixed-width image etc. Can I have text be aligned differently depending on the browser width/breakpoint?
The d-flex/mr-auto stuff, I am not wedded to. This was copied from Bootstrap 4 documentation code for the media object.
What's the way to go?
The "correct" approach is a subjective, but you can use the responsive utilities to change the text alignment at different breakpoints. text-md-left will keep item left align on larger screens, and then use text-center to center on smaller screens.
<!-- testimonial -->
<div class="container-fluid cxt-padded bg-faded">
<div class="container">
<div class="row">
<div class="col-md-2 text-md-left text-center">
<img class="rounded-circle" src="http://placehold.it/150x150" width="150" alt="Generic placeholder image">
</div>
<div class="col-md-10 text-md-left text-center">
<p class="lead">"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius venenatis neque, id commodo magna fermentum id." <i class="material-icons md-inverse pmd-sm">link</i></p>
<h2 class="mt-0">Joe Smith</h2>
<img src="http://placehold.it/150x40" class="img-fluid" width="150">
</div>
</div>
</div>
</div>
http://www.codeply.com/go/tuTd2OiZFx