Confused about how to properly use the media object within Bootstrap 3 - twitter-bootstrap-3

When using BS3 and patterns/designs that are similar to the media object layout:
<div class="media">
<a class="pull-left" href="#">
<img class="media-object" src="..." alt="...">
</a>
<div class="media-body">
<h4 class="media-heading">Media heading</h4>
...
</div>
</div>
Does it make more sense to recreate the pattern using BS3 grids (and thus built-in media queries, sorta like thumbnails)? For example:
<div class="row">
<a class="col-sm-5 col-md-4" href="#">
<img src="holder.js/100%x112" alt="media-like-object">
</a>
<div class="col-sm-6 col-md-7">
<h4 class="hidden-xs">Media heading</h4>
...
</div>
</div>
Or is there some way to utilize the built-in media object responsively? I guess I'm confused as the media object seems to be static. What am I missing?

Related

Vue JS: How to make two Vue Instances to work together on the same page?

I created a recipe website, you can find it here https://hungry-vegetarian.com/.
The tab on the index page is a vue instance. I'm trying to create a search bar that is also a vue instance.
The problem occurs when I try to display searched recipes on the index page. It just shows the search result on top of the search bar.
Ideally, only searched recipes should appear on the tab just like they are now but without any indications on top of the tab like Breakfast, Salad, Bakery, etc.
I don't know how to make two objects work together. For now, they work separately without communicating with each other.
SEARCH
<div id="search">
<div class="main-search">
<h1 class="search-question">What are you in the mood for?</h1>
<div class="search-box">
<input type="text" v-model="searchQuery" class="input-search" placeholder="Bread">
<button class="btn-search"><i class="fa fa-search"></i></button>
</div>
</div>
<div class="container">
<div class="recipe" v-for="post in filteredList">
<div v-if="searchQuery">
<a v-bind:href="post.url" class="recipe-card__card-link" target="_blank">
<img v-bind:src="post.image" alt="" class="recipe-card__image"/>
<div class="recipe-card__text-wrapper">
<h2 class="recipe-card__title">{{post.name}}</h2>
<div class="recipe-card__details-wrapper">
<p class="recipe-card__excerpt">{{post.body}}</p>
<a v-bind:href="post.url" class="recipe-card__read-more">Read more <i class="fa fa-arrow-right"></i></a>
</div>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
tab
<main id="tab">
<header>
<nav>
<ul>
<div id="arrow">
<span></span>
<span></span>
<span></span>
</div>
<li v-for="(tab, tabName) in tabs" :key="tabName">
<button class="tab" #click="setTabActive(tabName)" :class="{'active': tabName === activeTab}">
<span class="tab-copy">{{ tabName }}</span>
<span class="tab-background">
</span>
</button>
</li>
</ul>
</nav>
</header>
<article>
<div class="container">
<transition name="fade" mode="out-in" appear :duration="500">
<tab-content v-for="(tabContent, t) in tabs" :data="tabContent" :key="'content'+t" v-if="t === activeTab" inline-template>
<div class="content-wrapper">
<div class="recipes" v-for="(recipe, i) in data.recipes" :key="i">
<a v-bind:href="recipe.url" class="recipe-card__card-link"></a>
<img :src="recipe.image" alt="" class="recipe-card__image">
<div class="recipe-card__text-wrapper">
<h2 class="recipe-card__title">{{recipe.name}}</h2>
<div class="recipe-card__details-wrapper">
<p class="recipe-card__excerpt">{{recipe.body}}</p>
<a v-bind:href="recipe.url" class="recipe-card__read-more">Read more <i class="fa fa-arrow-right"></i></a>
</div>
</div>
</div>
</div>
</tab-content>
</transition>
</div>
</article>
</main>
I tried to combine instances search and tab into just one instance tab, but it always gives me a Vue warning:
[Vue warn]: Property or method "searchQuery" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
Also, I feel like I can have just the wrong approach to this problem I am trying to solve. Please, any suggestions are welcome. I am stuck.

Open bootstrap 3 accordion panel from another page

here is my accordion code:
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Collapsible Group Item #1
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body" id="myPanelContent">
Accordion Panel 1 Content
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
Collapsible Group Item #2
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
Accordion Panel 2 Content
</div>
</div>
</div>
</div>
I want a link from another page to open the No 1 panel (#myPanelContent) and show the content.
Link example:
Go to Panel 1 content
The true is that i used some solutions from stackoverflow but not worked. A detailed explain how to use the code will be much appreciated as I am novice in javascript.
Thanks in advance.
I'll add an answer in reply to my comment.
you need to check if there is a hash present in the URL, if so then show the accordion panel, you can accomplish this likes so:
$(function(){
// check if there is a hash in the url
if ( window.location.hash != '' )
{
// remove any accordion panels that are showing (they have a class of 'in')
$('.collapse').removeClass('in');
// show the panel based on the hash now:
$(window.location.hash + '.collapse').collapse('show');
}
});
This code uses jQuery of course, but i'd imagine you are using that already if you are using bootstrap's accordion?
give the link like above mentioned
and add the below script in the page where you want to show the active div
<script type="text/javascript">
var url = window.location.toString();
if (url.match('#')) {
$('.nav-tabs a[href="#'+url.split('#')[1]+'"]').tab('show');
}
</script>

Nested columns in panel heading

I wanted my panel heading to contain some text and a button, the former being left-aligned and the latter, right-aligned. But as soon as I apply the class row to my panel header, it breaks out of the parent div and takes up what I believe to be the container width.
Here's the code I'm using:
<div class="panel panel-primary">
<div class="panel-heading row">
<h4 class="col-md-11">Manage Your Subscriptions</h4>
<div>
<a href="#" class="btn btn-default col-md-1" >Log out</a>
</div>
</div>
<div class="panel-body">
</div>
</div>
And here's the result:
How can I correct this?
It seems to me like you just need to move the "row" to be inside the "panel-heading" rather than on the same level, as they both have relative CSS positioning properties. I tried the following code:
<div class="panel panel-primary">
<div class="panel-heading">
<div class="row">
<h4 class="col-md-11">Manage Your Subscriptions</h4>
<div class="col-md-1">
<a href="#" class="btn btn-default" >Log out</a>
</div>
</div>
</div>
<div class="panel-body">
Stackoverflow rocks!
</div>
</div>
and it gave me this output (which is what you're looking for, I hope):
I hope that helps
EDIT: I tried using "pull-right" as others have suggested and it seems to create more troubles as it messes the top/bottom margins as well since it makes the display block relative to container (Which I would generally recommend against doing, even if it works for you).
EDIT2: moved the "col-md-1" class into an encapsulating "div" to solve the button's margins' issue.
May be you need something like following?
<div class="panel panel-primary">
<div class="panel-heading">
<div class="row">
<div class="col-md-10 col-sm-10">
<h4>Manage Your Subscriptions</h4>
</div>
<div class="col-md-2 col-sm-2">
<a href="#" class="btn btn-default pull-right" >Log out</a>
</div>
</div>
</div>
<div class="panel-body">
</div>
</div>
Let me know if it works
You can use pull-left and pull-right instead of grid system, so the components will be rendered on single line even on small screen (if there is enough space):
<div class="panel panel-primary">
<div class="panel-heading">
<h4 class="pull-left">Manage Your Subscriptions</h4>
<span class="pull-right">
<a href="#" class="btn btn-default" >Log out</a>
</span>
<div class="clearfix"> </div>
</div>
<div class="panel-body">
</div>
</div>

Google Maps iframe not displaying correctly with Bootstrap Collapse panel collapsed

This should show exactly what I am struggling with:
http://jsfiddle.net/PaulHighten/c5knqdgd/
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingParis">
<h4 class="panel-title">
<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseParis" aria-expanded="true" aria-controls="collapseParis">
Eiffel Tower, Paris
</a>
</h4>
</div>
<div id="collapseParis" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingParis">
<div class="panel-body">
<div class="googlemap">
<iframe width="600" height="450" frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?q=Eiffel%20Tower%2C%20Avenue%20Anatole%20France%2C%20Paris%2C%20France&key=AIzaSyAFUKSu28KvFk67YcSlUWeUJ2TpcifSVmQ"></iframe>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingLondon">
<h4 class="panel-title">
<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseLondon" aria-expanded="false" aria-controls="collapseLondon">
Trafalgar Square, London
</a>
</h4>
</div>
<div id="collapseLondon" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingLondon">
<div class="panel-body">
<div class="googlemap">
<iframe width="600" height="450" frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?q=Trafalgar%20Square%2C%20London%2C%20United%20Kingdom&key=AIzaSyAFUKSu28KvFk67YcSlUWeUJ2TpcifSVmQ"></iframe>
</div>
</div>
</div>
</div>
The Paris panel shows the map correctly as it has a class of "in".
The London panel does not have that class which means bootstrap applies display: none; to that panel. I'm assuming that stops the iframe from running it's http request properly.
Can the Google Maps Embed API be used to achieve this? I've seen lots of questions relating to API v3 and initialize() calls, but struggled to find anything that related to making the embed iframe code work.
Thanks in advance.
=================
Edit: Code I used which solved the problem (slight modification of Christina's answer to only update the relevant iframe once):
$('[data-toggle="collapse"]').click('show.bs.collapse', function() {
var mapFrame = $($(this).attr('href') + ' .googlemap iframe');
if (!$(mapFrame).hasClass('map-refreshed')) {
mapFrame.attr('src', mapFrame.attr('src')+'');
mapFrame.addClass('map-refreshed');
}
});
Refresh the iframe source on the shown.bs.collapse OR show.bs.collapse function
$('[data-toggle="collapse"]').click('shown.bs.collapse', function() {
var googleIframe = $('.googlemap iframe');
googleIframe.attr('src',googleIframe.attr('src')+'');
});
DEMO: http://jsfiddle.net/ekba9y8w/
Assumes that the .googlemap is parent of the iframe.
Paul Highten's update so it doesn't keep on refreshing:
$('[data-toggle="collapse"]').click('show.bs.collapse', function() {
var mapFrame = $($(this).attr('href') + ' .googlemap iframe');
if (!$(mapFrame).hasClass('map-refreshed')) {
mapFrame.attr('src', mapFrame.attr('src')+'');
mapFrame.addClass('map-refreshed');
}
});

Accordion Inside of Carousel positioning Twitter Bootstrap-3

I have an accordion which I am placing inside of a carousel, it works fine but I cannot seem to get the position of the header to stay and the footer to be relative(it pushes upwards, rather than opening downward) if anyone has any clue please let me know(text is dummy text and will be replaced so ignore that please) I have tried changing the header position to absolute but it does nothing, and am not seeing anything regarding elemental inheritance that should be causing this, thank you!
Bootstrap Libraries:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
HTML
<div class="row">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="false">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="assets/img/a100Logo.png" alt="...">
<div class="carousel-caption">
<p class="headerLightBG">Sample Training Sessions</p>
<p class="textLightBG">
Beginning Front-End Web Development<br />
Introduction to Programming<br />
Intermediate Front-End Web Development: Web Applications<br />
Rapid Prototyping and Iterative Development <br />
Advanced Front-End Web Development: Mobile/Responsive Design <br />
Mobile Application Development: iOS/Android <br />
</p>
</div>
</div>
<div class="item">
<img src="assets/img/a100Logo.png" alt="...">
<div class="carousel-caption">
<p class="headerLightBG">Sample Projects</p>
<p class="textLightBG">
Write a program that successfully interacts with a commercial API.<br />
Create a dynamic front end for an iPhone or Android app.<br />
Design an engaging new web site for a technology company.<br />
Create a database system for matching Apprentices to Companies.<br />
Create a web application that allows consumers to locate fresh produce nearby.<br />
</p> </div>
</div>
<div class="item">
<img src="assets/img/a100Logo.png" alt="...">
<div class="carousel-caption">
<div class="col-lg-6">
<div class= "rightMargin">
<div class="panel-group" id="accordion">
<div class= "panel panel-default">
<a data-toggle="collapse" data-parent="#accordion" href="#FaqCost">
<div class= "panel-heading textLightBG headingColor">
<h4 class="panel-title fatFont">
Does A100 cost me anything?
</h4>
</div>
</a>
<div class="panel-collapse collapse" id="FaqCost">
<div class= "panel-body accText textDarkBG">
No! The program is completely free to Apprentices. This is because A100 is an initiative of Independent Software, with support from Connecticut Innovations and our Partner Companies.
</div>
</div>
</div>
<div class= "panel panel-default">
<a data-toggle="collapse" data-parent="#accordion" href="#FaqTime">
<div class= "panel-heading textLightBG headingColor">
<h4 class="panel-title fatFont">
What kind of time commitment does A100 require?
</h4>
</div>
</a>
<div class="panel-collapse collapse" id="FaqTime">
<div class= "panel-body accText textDarkBG">
The A100 training program requires a commitment of about 10-15 hours per week, including time spent in training sessions. The Program runs 2.5 months and repeats every quarter. Apprentices have been successful in the Program while also maintaining a rigorous academic schedule. A strong work ethic and willingness to learn new things is expected of all Apprentices.
</div>
</div>
</div>
<div class= "panel panel-default">
<a data-toggle="collapse" data-parent="#accordion" href="#FaqSchedule">
<div class= "panel-heading textLightBG headingColor">
<h4 class="panel-title fatFont">
What formal meeting times will I have to attend A100
</h4>
</div>
</a>
<div class="panel-collapse collapse" id="FaqSchedule">
<div class= "panel-body accText textDarkBG">
<p class="textDarkBG topMarginSmall centered">
While the schedule does change quarterly to suit the needs of the current Cohort, here is a sample schedule that Apprentices in the Spring Cohort of 2014 are expected to adhere to.
</P>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class= "leftMargin">
<div class="panel-group" id="accordion2">
<div class= "panel panel-default">
<a data-toggle="collapse" data-parent="#accordion2" href="#FaqFromMe">
<div class= "panel-heading textLightBG headingColor">
<h4 class="panel-title fatFont">
What does A100 want from me?
</h4>
</div>
</a>
<div class="panel-collapse collapse" id="FaqFromMe">
<div class= "panel-body accText textDarkBG">
In exchange for the training and opportunities we afford you to connect with local companies (as well as the free food!), we require that you sign an agreement to seek a paid apprenticeship at one of our Partner Companies in the month after graduating from the Program, and that you work there for at least three months. For more info, please read the full Terms and conditions of the Program.
</div>
</div>
</div>
<div class= "panel panel-default">
<a data-toggle="collapse" data-parent="#accordion2" href="#FaqSkills">
<div class= "panel-heading textLightBG headingColor">
<h4 class="panel-title fatFont">
How much programming experience do I need to apply?
</h4>
</div>
</a>
<div class="panel-collapse collapse" id="FaqSkills">
<div class= "panel-body accText textDarkBG">
Basic programming skills are needed in an object-oriented language of your choice (C++, Java, Python, Scala, Ruby, PHP, etc.), as well as some familiarity with HTML and CSS. Don't worry! We use a programming challenge as part of our application process to make sure everyone begins from a good platform – so you
</div>
</div>
</div>
<div class= "panel panel-default">
<a data-toggle="collapse" data-parent="#accordion2" href="#FaqTeach">
<div class= "panel-heading textLightBG headingColor">
<h4 class="panel-title fatFont">
What will A100 teach me?
</h4>
</div>
</a>
<div class="panel-collapse collapse" id="FaqTeach">
<div class= "panel-body accText textDarkBG">
A100 will teach you how to create working software products as part of a small development team. You'll learn the LAMP stack (Linux-Apache-MySQL-PHP), as well as improve your front end (HTML/CSS/JavaScript) development skills. We'll also expose you to practices used by working developers from the Connecticut tech
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END OF THE ACCORDION-->
</div>
</div>
</div><!-- carousel inner close-->
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div><!-- carousel close-->
</div><!-- row close-->
</div><!-- container close-->
</section>
CSS:
/* Accordion*/
.headingColor:hover
{
-webkit-transition: color 1s;
-moz-transition: color 1s;
-ms-transition: color 1s;
-o-transition: color 1s;
transition: color 1s;
color: #777;
}
.panel-heading a,
.panel-heading a:focus, .headingColor {
text-decoration: none;
color: #006496;
}
.accText
{
Background: #006496;
}
.unstyledList
{
list-style-type: none;
}
.fatFont{
font-weight: 600;
}
This is part of a much larger website, but this is the only section affected, and the accordion looks like it works fine when not placed within the carousel, perhaps that is just an issue of relative movement that the carousel brings to the users attention(I am very new to bootstrap), if so please let me know if this is impossible to fix
thanks!
panel heading and body needed to have overflow hidden tricks done to them