Ont End Libraries Bootstrap
Ont End Libraries Bootstrap
To get started, we should nest all of our HTML (except the link tag and the style element) in a
div element with the class container-fluid.
h2 {
font-family: Lobster, Monospace;
}
p{
font-size: 16px;
font-family: Monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
.smaller-image {
width: 100px;
}
</style>
<div class="container-fluid">
<h2 class="red-text">CatPhotoApp</h2>
It would be great if this image could be exactly the width of our phone's screen.
Fortunately, with Bootstrap, all we need to do is add the img-responsive class to your image. Do
this, and the image should perfectly fit the width of your page.
Remember that you can add several classes to the same element by separating each of them with a
space.
Create a new button element below your large kitten photo. Give it the btn and btn-default
classes, as well as the text of "Like".
Note that this button will still need the btn and btn-block classes.
Note that these buttons still need the btn and btn-block classes.
Note that these buttons still need the btn and btn-block classes.
Bootstrap has different column width attributes that it uses depending on how wide the user's screen is.
For example, phones have narrow screens, and laptops have wider screens.
Take for example Bootstrap's col-md-* class. Here, md means medium, and * is a number specifying
how many columns wide the element should be. In this case, the column width of an element on a
medium-sized screen, such as a laptop, is being specified.
In the Cat Photo App that we're building, we'll use col-xs-*, where xs means extra small (like an
extra-small mobile phone screen), and * is the number of columns specifying how many columns wide
the element should be.
Put the Like, Info and Delete buttons side-by-side by nesting all three of them within one <div
class="row"> element, then each of them within a <div class="col-xs-4"> element.
The row class is applied to a div, and the buttons themselves can be nested within it.
<div class="row">
<div class="col-xs-4">
<button class="btn btn-block btn-primary">Like</button></div>
<div class="col-xs-4">
<button class="btn btn-block btn-info">Info</button></div>
<div class="col-xs-4">
<button class="btn btn-block btn-danger">Delete</button></div>
</div>
Bootstrap: Ditch Custom CSS for Bootstrap
We can clean up our code and make our Cat Photo App look more conventional by using Bootstrap's
built-in styles instead of the custom styles we created earlier.
Don't worry - there will be plenty of time to customize our CSS later.
Delete the .red-text, p, and .smaller-image CSS declarations from your style element so
that the only declarations left in your style element are h2 and thick-green-border.
Then delete the p element that contains a dead link. Then remove the red-text class from your h2
element and replace it with the text-primary Bootstrap class.
Finally, remove the "smaller-image" class from your first img element and replace it with the img-
responsive class.
Nest your first image and your h2 element within a single <div class="row"> element. Nest your
h2 element within a <div class="col-xs-8"> and your image in a <div class="col-xs-
4"> so that they are on the same line.
Notice how the image is now just the right size to fit along the text?
<div class="container-fluid">
<div class="row">
<div class="col-xs-8">
<h2 class="text-primary text-center">CatPhotoApp</h2>
</div>
<div class="col-xs-4">
<a href="#"><img class="img-responsive thick-green-border" src="https://bit.ly/fcc-
relaxing-cat" alt="A cute orange cat lying on its back."></a>
</div>
</div>
Use Font Awesome to add a thumbs-up icon to your like button by giving it an i element with the
classes fas and fa-thumbs-up. Make sure to keep the text "Like" next to the icon.
Give your form's text input field a class of form-control. Give your form's submit button the
classes btn btn-primary. Also give this button the Font Awesome icon of fa-paper-plane.
All textual <input>, <textarea>, and <select> elements with the class .form-control
have a width of 100%.
Nest both your form's text input and submit button within a div with the class row. Nest your
form's text input within a div with the class of col-xs-7. Nest your form's submit button in a
div with the class col-xs-5.
This is the last challenge we'll do for our Cat Photo App for now. We hope you've enjoyed learning
Font Awesome, Bootstrap, and responsive design!
<div class="row">
<div class="col-xs-7">
<input type="text" class="form-control" placeholder="cat photo URL" required>
</div>
<div class="col-xs-5">
<button type="submit" class="btn btn-primary"><i class="fa fa-paper-plane"></i>
Submit</button>
</div>
</div>
<div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3>
</div>
<div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row">
<div class="col-xs-6"></div>
<div class="col-xs-6"></div>
</div>
</div>
Nest one div element with the class well within each of your col-xs-6 div elements.
<div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row">
<div class="col-xs-6">
<div class="well">
</div>
</div>
<div class="col-xs-6">
<div class="well">
</div>
</div>
</div>
</div>
Nest three button elements within each of your well div elements.
<div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row">
<div class="col-xs-6">
<div class="well">
<button></button>
<button></button>
<button></button>
</div>
</div>
<div class="col-xs-6">
<div class="well">
<button></button>
<button></button>
<button></button>
</div>
</div>
</div>
</div>
Apply both the btn and btn-default classes to each of your button elements.
Each id must be unique to a specific element and used only once per page.
Let's give a unique id to each of our div elements of class well.
Above your right-well, inside its col-xs-6 div element, add a h4 element with the text #right-
well.
Make sure that target1 to target3 are in #left-well, and target4 to target6 are in
#right-well.
<div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row">
<div class="col-xs-6">
<h4>#left-well</h4>
<div class="well" id="left-well">
<button class="btn btn-default target"
id="target1">#target1</button>
<button class="btn btn-default target"
id="target2">#target2</button>
<button class="btn btn-default target"
id="target3">#target3</button>
</div>
</div>
<div class="col-xs-6">
<h4>#right-well</h4>
<div class="well" id="right-well">
<button class="btn btn-default target"
id="target4">#target4</button>
<button class="btn btn-default target"
id="target5">#target5</button>
<button class="btn btn-default target"
id="target6">#target6</button>
</div>
</div>
</div>
</div>
Add a comment at the top of your HTML that says Code below this line should not be
changed