Create a card with wave in Polymer - polymer

I try to learn Polymer and until now, I think I am in a good way. However, I found a framework which has the same Google Material Design and I am trying to implement on of their tutorials to Polymer code.
The framework is: http://materializecss.com/ and the component I try to implement is the Card reveal
I have the code of how it should be on materializecss
<div class="col l4 m4 s1">
<div class="card">
<div class="card-image waves-effect waves-block waves-light">
<img class="responsive-img" src="/static/images/myimage.png">
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-4">Training Estimation <i class="mdi-navigation-more-vert right"></i></span>
<p>This is a link</p>
</div>
<div class="card-reveal">
<span class="card-title grey-text text-darken-4">Card Title <i class="mdi-navigation-close right"></i></span>
<p>Here is some more information about this product that is only revealed once clicked on.</p>
</div>
</div>
</div>
However, I don't know how to start and rewrite the same feature on Polymer directly.

Can be done using polymer core-animated-pages.
Demo and the code: https://github.com/DinethH/card-reveal
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/paper-shadow/paper-shadow.html">
<link rel="import" href="../../bower_components/font-roboto/roboto.html">
<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../bower_components/core-animated-pages/core-animated-pages.html">
<link rel="import" href="../../bower_components/core-animated-pages/transitions/slide-up.html">
<link rel="import" href="../../bower_components/core-animated-pages/transitions/slide-down.html">
<link rel="import" href="../../bower_components/core-animated-pages/transitions/cross-fade.html">
<polymer-element name="card-reveal" center layout>
<template>
<style>
paper-shadow,
core-animated-pages section {
height: 500px;
width: 500px;
}
core-animated-pages section {
overflow: hidden;
}
h3 {
font-weight: 300;
font-size: 26px;
margin: 0;
padding: 0;
padding-bottom: 10px;
}
.card-content,
.card-reveal {
padding: 20px;
background: white;
height: 500px;
}
a {
color: orange;
text-transform: uppercase;
}
</style>
<paper-shadow>
<core-animated-pages transitions="slide-up" selected="{{selected}}">
<section>
<div>
<img src="http://lorempixel.com/500/380/">
<div>
<div class="card-content">
<div layout horizontal>
<div flex>
<h3>{{item.title}}</h3>
</div>
<div>
<paper-icon-button on-tap="{{reveal}}" icon="more-vert"></paper-icon-button>
</div>
</div>
<a>This is a link</a>
</div>
</div>
</div>
</section>
<section>
<div class="card-reveal" slide-up cross-fade>
<div layout horizontal>
<div flex>
<h3>{{item.title}}</h3>
</div>
<div>
<paper-icon-button on-tap="{{reveal}}" icon="close"></paper-icon-button>
</div>
</div>
<div>
{{item.more}}
</div>
</div>
</section>
</core-animated-pages>
</paper-shadow>
</template>
<script>
Polymer({
created: function () {
this.item = {
title: "Card Title",
more: "Here is some more information about this product that is only revealed once clicked on."
};
},
reveal: function () {
if (this.selected == 0) {
this.selected = 1;
} else {
this.selected = 0;
}
}
});
</script>
</polymer-element>

Related

Using two (owl) carousel on a single page is not working

I am trying to use two owl carousels on my page but I can't.
Gif: https://gyazo.com/51620bc2fa6183bdcaab511632e1eb57
The first one is working perfectly (the one in the top on the gif)
but the second one (the one below on the gif) is not working. It is set to show 4 images instead of the 2 I set. I don't know what to do
This one is working well:
<body>
<!-- MENU-->
<section>
<div class="owl-carousel owl-theme">
<div class="item">
<img src="img/image1.jpg">
</div>
<div class="item">
<img src="img/image2.jpg">
</div>
<div class="item">
<img src="img/image3.jpg">
</div>
<div class="item">
<img src="img/image4.jpg">
</div>
<div class="item">
<img src="img/image5.jpg">
</div>
<div class="item">
<img src="img/image6.jpg">
</div>
<div class="item">
<img src="img/image7.jpg">
</div>
<div class="item">
<img src="img/image8.jpg">
</div>
<div class="item">
<img src="img/image9.jpg">
</div>
</div>
<!--script MENU-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js" integrity="sha512-bPs7Ae6pVvhOSiIcyUClR7/q2OAsRiovw4vAkX+zJbw3ShAeeqezq50RIIcIURq7Oa20rW2n2q+fyXBNcU9lrw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
$(document).ready(function(){
$(".owl-carousel").owlCarousel({
loop:true,
responsive: {
0 : {
items : 1
},
600 : {
items : 2
},
1200 : {
items : 4
}
},
autoplay: true,
autoplayTimeout: 1500
});
})
</script>
</section>
But this one is not working well:
<header>
<div class="owl-carousel owl-theme">
<div class="item"><img src="/img/Group 1.jpg" alt="slide1" /></div>
<div class="item"><img src="/img/Group 2.jpg" alt="slide1" /></div>
</div>
<script>
$('.owl-carousel').owlCarousel({
loop:true,
margin:0,
nav:true,
dots:true,
responsive:{
0:{
items:1
},
600:{
items:1
},
1000:{
items:1
}
}
})
</script>
<!--Script HEADER-->
<script src="https://owlcarousel2.github.io/OwlCarousel2/assets/vendors/jquery.min.js"></script>
<script src="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/owl.carousel.js"></script>
</header>
Href Menu:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css" integrity="sha512-tS3S5qG0BlhnQROyJXvNjeEM4UpMXHrQfTGmbQ1gKmelCxlSEBUaxhRBj/EFTzpbP4RVSrpEikbmdJobCvhE3g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css" integrity="sha512-sMXtMNL1zRzolHYKEujM2AqCLUR9F2C4/05cdbxjjLSRvMQIciEPCQZo++nk7go3BtSuK9kfa/s+a4f4i5pLkw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
Href Header:
<link rel="stylesheet" href="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/assets/owl.carousel.min.css">
<link rel="stylesheet" href="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/assets/owl.theme.default.min.css">
Css(header):
*{ margin:0; padding:0; box-sizing:border-box}
body {
background-color: #fff;
}
.item img{ height:450px; width:100%; object-fit:cover}
.owl-nav {
position: absolute;
top: 50%;
transform: translateY(-50%);
z-index: 9999;
width: 100%;
}
.owl-nav button {
background: #fff !important;
width: 50px;
height: 50px;
display: block
}
.owl-nav button.owl-next {
float: right;
}
.owl-nav button.owl-prev {
float: left;
}
.owl-dots {
position: absolute;
bottom: 5%;
left: 0;
right: 0;
}
Both scripts with which you run the carousel are looking for a block with a class ".owl-carousel" and find them both. So, we have conflict. Both carousels initialized by every script snippets, but with diferent options.
You must be better - add diferent ID to every carousel and inintialize them separately (individually):
<div id="carousel-1" class="owl-carousel owl-theme">
...
</div>
<div id="carousel-2" class="owl-carousel owl-theme">
...
</div>
<script>
$("#carousel-1").owlCarousel({
items: 4,
...
});
</script>
<script>
$("#carousel-2").owlCarousel({
items: 2,
...
});
</script>

Codepen vs Local not matching up

I edited the settings in codepen to use bootstrap for css but it will not display page as it does locally.
Here is what the page looks like locally.
Here is the local code with the paragraph content shortened.
<html>
<head>
<script src="js/jquery-1.9.1.js"></script>
<script src="js/bootstrap.js"></script>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="font-awesome-4.6.1/fonts/fontawesome-webfont.svg">
<style>
body{
margin: 50px;
background-color: black;
}
.container{
border: 3px solid red;
width: 80%;
}
</style>
</head>
<body>
<div class="container panel panel-default">
<div class="row text-center">
<div class="col-xs-12">
<h2>William "Bill" Paxton</h2>
<p><em>May 17, 1955 – February 25, 2017</em></p>
</div>
</div>
<figure class="figure text-center">
<img src="images/download.jpeg" width="30%" alt="image of Bill Paxton">
<figcaption class="figure-caption">An image of Bill Paxton</figcaption>
</figure>
<div class="well">
<section>
<p>...</p>
<h3>Early Life</h3>
<p>...</p>
<h3>Career</h3>
<p>...</p>
<h3>Personal Life</h3>
<p>...</p>
</section>
</div>
<div class="well">
<section>
<h3>Click here check out is filmography on IMDB</h3>
</section>
</div>
</div>
</body>
</html>
Here is what it looks like on codepen.
http://codepen.io/centem/pen/PbNbvR
What am I missing? Thanks in advance.
The default cdn that codepen.io uses for Bootstrap is for the Bootstrap 4 alpha. I've had problems with things not displaying properly as well.
Use this cdn instead:
https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css

Have BootStrap buttons fill the height of the screen

I'm creating a simple web page that will have three large buttons that should fill the entire page (ie, they span the width of the page, and should take up 33.3% of the height for each.) I have the width part working, but I am unsure how to get the heights part working. This is my code so far.
<html>
<link rel="stylesheet" href="./bootstrap.min.css"/>
<link rel="stylesheet" href="./bootstrap-theme.min.css"/>
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet" type="text/css">
<div class="container-fluid">
<div class="row">
<div class="jumbotron">
<span style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif">
<div class="col-md-4">
<i class = "fa fa-search fa-3x"></i> &nbsp<h1>Catalogue Search</h1>
</div>
<div class="col-md-4">
<i class = "fa fa-sign-in fa-3x"></i> &nbsp<h1>Library Account Login</h1></button>
</div>
<div class="col-md-4">
<i class = "fa fa-map-marker fa-3x"></i> &nbsp<h1>Hours and Locations</h1></button>
</div>
</span>
</div>
</div>
</div>
</html>
The following fiddle link may solve your problem.
Codes are as follows:
HTML:
<div class="container-fluid">
<div class="row">
<button id="catalogSearch" class="btn btn-default">Catalogue Search </button>
</div>
<br/><br/>
<div class="row">
<button type="button" id = "AccountLogin" class="btn btn-default">Library Account Login</button>
</div>
<br/><br/>
<div class="row">
<button id ="hrsLocations" class="btn btn-default btn-lg"> Hours and Locations</button>
</div>
</div>
CSS:
.btn
{
width:100%;
padding: 12%;
}
JavsScript
document.getElementById("catalogSearch").onclick = function () {
location.href = "https://encore.mpl.on.ca/iii/mobile/homepage?lang=eng";
};
document.getElementById("AccountLogin").onclick = function () {
location.href = "https://encore.mpl.on.ca/iii/mobile/homepage/Sdologin?lang=eng&loginReason=doDefault";
};
document.getElementById("hrsLocations").onclick = function () {
location.href = "http://www.mpl.on.ca/hours.php";
};
You haven't specified whether you are using Bootstrap v3 or v4.
You should only be using .col-*-* as children of .row elements or any other elements with a default margin: 0 -15px (such as .form-groups).
You are using .col-*-4 when you don't want your element to be 1/3 of their parent width.
You're using 3 <h1> tags on the same page, which is a very big no-no SEO-wise.
Probably the easiest way to achieve what you want, using Bootstrap v3 (which is what I assume you're using), would be using a .btn-block combined with flexbox. Please also note I've made significant changes to markup (yours is invalid).
body {
margin: 0;
}
div.jumbotron {
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
min-height: 100vh;
margin-bottom: 0;
}
.jumbotron > .btn-block {
display: flex;
flex-direction: column;
min-height: calc(100vh - 60px);
align-items: stretch;
}
.jumbotron > .btn-block > .btn {
flex-grow: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
#media (min-width: 768px) {
.jumbotron > .btn-block {
min-height: calc(100vh - 120px);
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="jumbotron">
<div class="btn-group-vertical btn-group btn-block">
<i class = "fa fa-search fa-3x"></i><h1>Catalogue Search</h1>
<i class = "fa fa-sign-in fa-3x"></i><h1>Library Account Login</h1>
<i class = "fa fa-map-marker fa-3x"></i><h1>Hours and Locations</h1>
</div>
</div>
</div>
</div>
Don't forget to autoprefix
Try this without bootstrap :)
// this will call the button and design
.button {
background-color: gray;
color: #FFFFFF;
padding: 10px;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
margin:10px
}
// this will assign sizes of the button you want
.btnbig {
width: 99%;
height: 500px;
}
//btnbig is the class of your button you want to modify
<div class="button btnbig">A big button</div>
is this clear now ? im sorry (Im newbie)
If I understand the question correctly then you can use CSS calc to set the height as a percentage of the page.
.btn-block {
display: block;
width: 100%;
height: calc(100vh/3);
}

Display Text Over Hover in Bootstrap

I'm trying to add text on hover over an image inside a row and col-md-3. I want it to change opacity to set ideal while displaying text in centered inside the image.
I have the opacity hover down but I'm struggling with the data-hover class and I have no clue where to place the text I want inside HTML and CSS
I've included a fiddle here with all the work I have accomplished thus far: https://jsfiddle.net/a8u05mw1/
HTML:
<div class="container-fluid">
<div id="wrapper">
<div class="row">
<div class="col-md-3">
<img class="img-responsive" src=https://s-media-cache-ak0.pinimg.com/736x/e6/61/fe/e661fe4b71debff151e6eb3fcd670bbe.jpg>
</div>
<div class="col-md-3">
<img class="img-responsive" src=https://www.roys.co.uk/media/wysiwyg/FASHION/MENSWEAR-AW16-JOULES-COAT.jpg>
</div>
<div class="col-md-3">
<img class="img-responsive" src=https://s-media-cache-ak0.pinimg.com/736x/b1/5e/38/b15e38cd4864c85a52897d906a88710c.jpg>
</div>
<div class="col-md-3">
<img class="img-responsive" src=https://static1.squarespace.com/static/56b6a4bd07eaa0d2d0eddb7f/58678682bebafb6e8b0a4e2a/5867868b893fc0dff9edd97d/1483179664063/Andrew+Belliot-011.jpg?format=500w>
</div>
</div>
</div
</div>
CSS:
#wrapper img {
width: 100%;
transition-duration: 0.8s;
}
.col-md-3 {
padding: 0;
}
#wrapper img:hover {
opacity: 0.8;
transition-duration: 0.8s;
}
Answer 1: Without Bootstrap
jsfiddle answer 1
<div class="container-fluid">
<div id="wrapper">
<div class="row">
<div class="col-md-3">
<div class="img-container">
<img class="img-responsive" src=https://s-media-cache-ak0.pinimg.com/736x/e6/61/fe/e661fe4b71debff151e6eb3fcd670bbe.jpg style="width:100%;">
<div class="img-hover-text centered">Your text here</div>
</div>
</div>
<div class="col-md-3">
<div class="img-container">
<img class="img-responsive" src=https://s-media-cache-ak0.pinimg.com/736x/b1/5e/38/b15e38cd4864c85a52897d906a88710c.jpg>
<div class="img-hover-text centered">Your text here</div>
</div>
</div>
<div class="col-md-3">
<div class="img-container">
<img class="img-responsive" src=https://static1.squarespace.com/static/56b6a4bd07eaa0d2d0eddb7f/58678682bebafb6e8b0a4e2a/5867868b893fc0dff9edd97d/1483179664063/Andrew+Belliot-011.jpg?format=500w>
<div class="img-hover-text centered">Your text here</div>
</div>
</div>
</div>
</div>
</div>
Note: I removed the image which is no more available.
.container {
position: relative;
text-align: center;
color: white;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
/* original example from question */
.img-responsive:hover + .img-hover-text {
display: block;
}
.img-hover-text:hover {
/* needed for the text to stay visible
when the cursor it just over it.
*/
display: block;
}
.img-hover-text {
display: none;
color: white;
font-size: 20px;
}
Answer 2: With Bootstrap
jsfiddle answer 2
I made a new example inspired with your code, but using tooltips from Booststrap / Popper.js. I used the bootstrap starter template to quickstart the use of Boostrap.
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<h1>Hello, world!</h1>
<div class="img-container">
<img class="img-responsive" src=https://s-media-cache-ak0.pinimg.com/736x/e6/61/fe/e661fe4b71debff151e6eb3fcd670bbe.jpg style="width:100%;" data-toggle="tooltip" data-placement="auto" title="This is a Tooltip">
<div class="img-hover-text centered">Your text here</div>
</div>
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="top" title="Tooltip on top">
Tooltip on top
</button>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
body {
padding: 20px;
}
.img-container {
position: relative;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.img-responsive:hover + .img-hover-text {
display: block;
}
.img-hover-text:hover {
/* needed for the text to stay visible
when the cursor it just over it.
*/
display: block;
}
.img-hover-text {
display: none;
color: white;
font-size: 20px;
}
// Enable tooltip everywhere
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
Explaining Answer 1:
You want two things:
First, center some text over an image.
Then, apply a hover effect on the text so that it only appears when the cursor is hovering the image.
You can get a cool tutorial on how to center text over an image here | w3school.
<div class="container">
<img src="https://s-media-cache-ak0.pinimg.com/736x/e6/61/fe/e661fe4b71debff151e6eb3fcd670bbe.jpg" alt="Snow" style="width:100%;">
<div class="centered">Centered</div>
</div>
.container {
position: relative;
text-align: center;
color: white;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
This will give you the following picture:
Warning: Don't be like me. Don't waste your time on a <p>. Use a <div> for the text directly.
<div class="container">
<img src="https://s-media-cache-ak0.pinimg.com/736x/e6/61/fe/e661fe4b71debff151e6eb3fcd670bbe.jpg" alt="Snow" style="width:100%;">
<p class="centered">Not Centered</p>
</div>
Otherwise you will see this:
Ok, now we have our centered text. Time to make it disappear. Let's go back to your code and modify it.
<div class="col-md-3">
<div class="img-container">
<img class="img-responsive" src=https://s-media-cache-ak0.pinimg.com/736x/e6/61/fe/e661fe4b71debff151e6eb3fcd670bbe.jpg style="width:100%;">
<div class="img-hover-text centered">Your text here</div>
</div>
.img-responsive:hover + .img-hover-text {
display: block;
}
.img-hover-text {
display: none;
color: white;
font-size: 20px;
}
However, if we stop there, something will be wrong. When we hover the cursor right on top of the text area, the text disappear! To correct that, add a last css rule:
/* needed for the text to stay visible
when the cursor it just over it. */
.img-hover-text:hover {
display: block;
}
Explaining answer 2
The idea is not to do the stuff we made by hand, by using a library: namely Popper.js which fortunately is used by Boostrap. We include the tooltip with data-toggle="tooltip" data-placement="auto" title="This is a Tooltip" inside the element we want to display the tooltip on hover. Here inside <img>.
To make is works, we also need to import the necessary library. Don't forget the <script src="https://cdn.jsdelivr.net/npm/popper.js#1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> at the end, just before closing </body> flag.
Done!
Long story short for those looking for a Boostrap answer.
Add a tooltip in the flag you want.
<img src=... data-toggle="tooltip" data-placement="auto" title="This is a Tooltip">
// Enable tooltip everywhere
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
Don't forget to add Popper.js which is needed for the tooltip.
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>

Input and label on same line without form-horizontal and col-XX classes

I want to have label and input in one line. I know about form-horizontal, form-inline. But I have some p tags above my label and input and them all look good.
<div class="container">
<div class="row">
<p class="pull-left">Name: <strong>John Smith</strong></p>
<p class="pull-right">Projects completed: 4</p>
</div>
<div class="row c-notes">
<label>Manager Note:</label>
<input class="form-control">
</div>
</div>
I want input takes all space after label. I know that I can use col-** classes but then on high resolution there will be some space between label and input, but I don't need this space.
Look at DEMO
Use CSS Flexbox. Like:
.c-notes {
display: flex;
align-items: center;
}
.c-notes label {
flex: 0 auto;
padding-right: 10px;
}
.c-notes input {
flex: 1;
}
Have a look at the first textfield in the snippet below or have a look at the updated JSBin.
.c-notes {
display: flex;
align-items: center;
}
.c-notes label {
flex: 0 auto;
padding-right: 10px;
}
.c-notes input {
flex: 1;
}
.comment {
font-size: 12px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<p class="comment">My try, I just use witdh proeprty, but it also has problem with different resolution.</p>
<div class="container">
<div class="row">
<p class="pull-left">Name: <strong>John Smith</strong></p>
<p class="pull-right">Projects completed: 4</p>
</div>
<div class="row c-notes">
<label>Manager Note:</label>
<input class="form-control">
</div>
</div>
<hr/>
<p class="comment">Option 2, use col-xx class, but there is space between label and input, increae ouput window and you will see.</p>
<div class="container">
<div class="row">
<p class="pull-left">Name: <strong>John Smith</strong></p>
<p class="pull-right">Projects completed: 4</p>
</div>
<div class="row">
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-2">Manager Note:</label>
<div class="col-sm-10">
<input type="text" class="form-control" placeholder="Note">
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</body>
</html>
Hope this helps!
Just Add below css rules.
.c-notes {
display: flex;
}
See below
.c-notes{
display: flex;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<p class="pull-left">Name: <strong>John Smith</strong></p>
<p class="pull-right">Projects completed: 4</p>
</div>
<div class="row c-notes">
<label>Manager Note:</label>
<input class="form-control">
</div>
</div>
</div>