I'm trying to create a page where clicking on a thumbnail image in the left column reveals text in the right column. Then there would be a number of thumbnails which each have their own text that appears in the same place in the right column when clicked.
I'm wondering if there are any CSS or jquery projects out there that do this kind of thing?
Thanks
I think this is what you are wanting, i made a jsFiddle with it.
HTML:
<div id="wrapper">
<div id="left">
<p>THUMBNAIL #1
</p>
<p>THUMBNAIL #2
</p>
<p>THUMBNAIL #3
</p>
</div>
<div id="right">
<!-- Each div here will contain the text to be show on the right -->
<div id="textOne" class="text" style="display:block;">
<h1>one</h1>
<p>Zzril amet nisl consequat claritas litterarum. In aliquam dolore qui diam veniam. Ut exerci ullamcorper ut sit dolor.</p>
</div>
<div id="textTwo" class="text">
<h1>two</h1>
<p>Qui nobis nulla eu in lectores. Legunt possim diam me nisl nostrud. Legere claritatem duis anteposuerit aliquip et.</p>
</div>
<div id="textThree" class="text">
<h1>three</h1>
<p>Qui nobis nulla eu in lectores. Legunt possim diam me nisl nostrud. Legere claritatem duis anteposuerit aliquip et.</p>
</div>
</div>
</div>
CSS:
a {
text-decoration:none;
}
#wrapper {
width:600px;
}
#left {
margin-top:100px;
overflow:hidden;
float:left;
width:20%;
}
#right {
overflow:hidden;
float:left;
width:80%;
}
Javascript (jQuery 1.9.1)
$(".text").hide();
$("#left a.one").click(function () {
$(".text").hide();
$("#textOne").fadeIn();
return false;
});
$("#left a.two").click(function () {
$(".text").hide();
$("#textTwo").fadeIn();
return false;
});
$("#left a.three").click(function () {
$(".text").hide();
$("#textThree").fadeIn();
return false;
});
Related
This is my Vue code and I am using bootstrap-vue, I am using the sidebar inside the card body Ideally it should only appear inside the card-body but it's not working. How can I make it fit either inside the outer div or b-card body?
<template>
<div class="">
<div>
<b-card title="Card Title" body-class="text-center" header-tag="nav">
<template v-slot:header>
<b-nav card-header tabs>
<b-nav-item active>Active</b-nav-item>
<b-nav-item>Inactive</b-nav-item>
<b-nav-item disabled>Disabled</b-nav-item>
</b-nav>
</template>
<b-card-text>
With supporting text below as a natural lead-in to additional content.
</b-card-text>
<b-card-body>
<b-sidebar visible="true" title="Sidebar" shadow>
<div class="px-3 py-2">
<p>
Cras mattis consectetur purus sit amet fermentum. Cras justo
odio, dapibus ac facilisis in, egestas eget quam. Morbi leo
risus, porta ac consectetur ac, vestibulum at eros.
</p>
<b-img
src="https://picsum.photos/500/500/?image=54"
fluid
thumbnail
></b-img>
</div>
</b-sidebar>
</b-card-body>
<b-button variant="primary">Go somewhere</b-button>
</b-card>
</div>
</div>
</template>
The sidebar wasn't really designed to be inside a container. but instead be used as an off-canvas menu for the entire page.
However, you can hack it a bit to fit your needs with a little CSS.
The sidebar is position: fixed by default, so that it is fixed to the viewport.
You need to change this to position: absolute, so that it will be positioned based on the closest parent that is position: relative. In this case that's the card.
In the snippet the sidebar goes over the title. If you want it only inside the body, all you need to be is wrap it in another element with position: relative
new Vue({
el: "#app"
});
body {
padding: 1rem;
}
.my-sidebar.b-sidebar-outer {
position: absolute !important;
height: 100% !important;
}
.my-sidebar .b-sidebar {
position: absolute !important;
height: 100% !important;
}
<link href="https://unpkg.com/bootstrap#4.4.1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://unpkg.com/bootstrap-vue#2.13.0/dist/bootstrap-vue.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.js"></script>
<script src="https://unpkg.com/bootstrap-vue#2.13.0/dist/bootstrap-vue.js"></script>
<div id="app">
<b-button v-b-toggle.sidebar-1>Toggle Sidebar</b-button>
<!-- The height is only here for the example -->
<b-card style="min-height: 300px;" class="overflow-hidden" no-body>
<b-card-header>
<b-card-title>Title</b-card-title>
</b-card-header>
<b-sidebar id="sidebar-1" title="Sidebar" shadow class="my-sidebar">
<div class="px-3 py-2">
<p>
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis
</p>
<b-img src="https://picsum.photos/500/500/?image=54" fluid thumbnail></b-img>
<p>
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis
</p>
</div>
</b-sidebar>
</b-card>
</div>
I solved by modifying the style of the element by using JQuery where top': '60px' is going to be the hight of the navbar.
mounted() {
$('#sidebar-1').css(
{'top': '60px',
'opacity': '80%'
}
);
},
I've been searching for an answer all day and have not quite found one.
Using Bootstrap 4, how does one wrap text around an image using d-flex or flex-wrap in with the grid layout with columns and rows. I have provided my code and two image examples. I hope this is possible.
I have viewed this example - https://www.codeply.com/api/run but it's quite different whereas the image is fixed sizing but we need the image to be responsive.
Cheers and thanks in advance.
Example image here with photo
Example diagram here
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<div class="container" style="margin-top: 30px;">
<div class="row" style="border: 1px solid #ddd;">
<div class="col-sm-6 col-lg-6 col-xl-5">
<div class="imagebox">
<figure>
<img class="rounded img-fluid" src="https://www.bbh.co.nz/hostelImages/hi_2243_gal.jpg" alt="" />
<figcaption class="imagebox-desc">VERANDAHS<br>
<span class="small">Superior Central Location...</span></figcaption>
</figure>
</div>
</div>
<div class="col-sm-6 col-lg-6 col-xl-7">
<div class="row">
<div class="col-12"><small>BPP Rating - 88%</small></div>
<!-- this below line will wrap on all screens -->
<div class="col-6"><small>Online Rating - 88% </small></div>
<div class="col-6 text-right"><small>Total Beds - 50</small></div>
</div>
<hr style="margin: 0.5rem 0;">
<div class="row">
<div class="col-sm-6 col-6"><small>Share Rooms from NZD $30</small></div>
<div class="col-sm-6 col-6 text-right"><small>Private Rooms from NZD $60</small></div>
</div>
<div class="row">
<div class="col-12 d-none d-lg-block d-xl-block">Lorem ipsum dolor sit amet, at assum perpetua dissentiet sit, et sea probatus sententiae ullamcorper, voluptatibus signiferumque ex has. No vel postea scripta alienum, eam te enim feugiat ornatus. Exerci quidam melius has ad. Mel ut ludus choro
instructior. Erat dictas antiopam quo ea, pri at audiam offendit.Cetero albucius pri ne, erant nobis aliquip cu sit, eam dolore.</div>
</div>
</div>
</div>
you can try like this, by giving background-image on the row and its property to set it one center of the div
here is an example - https://jsfiddle.net/erymag7b/27/
you can use float:left in .imagebox to wrap text around an image and use clean:both in P tag to let text under an image
https://codepen.io/lichunbin814/pen/yqEOKm?editors=1100
tip : Avoid Inline Styles for CSS Design
.imagebox {
float: left;
margin-right: 1em;
}
div.container {
max-width: 100%;
}
figcaption.imagebox-desc {
top: 0;
position: absolute;
left: 0;
color: white;
background: rgba(4, 4, 4, 0.8);
width: 100%;
padding: 0.7rem 0 0.5rem 1.2rem;
font-size: 1.2rem;
}
.imagebox-inner {
position: relative;
display: inline-block;
}
.img {
width: 100%;
}
#media (max-width: 768px) {
.text {
clear: both;
}
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col-12">
<div class="imagebox">
<figure class="imagebox-inner">
<img class="rounded img-fluid" src="https://www.bbh.co.nz/hostelImages/hi_2243_gal.jpg" alt="" />
<figcaption class="imagebox-desc">VERANDAHS<br>
<span class="small">Superior Central Location...</span></figcaption>
</figure>
</div>
<div><small>BPP Rating - 88%</small></div>
<div class="d-flex justify-content-between"> <small>Online Rating - 88% </small> <small>Total Beds - 50</small></div>
<hr class="m3">
<div class="d-flex justify-content-between"><small>Share Rooms from NZD</small><small>Private Rooms from NZD</small></div>
<div class="d-flex justify-content-between"><small>$30</small><small>$60</small></div>
<p class="mt-2 text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque explicabo aspernatur delectus voluptate, nesciunt quibusdam ab reprehenderit, non et temporibus. Aut commodi, voluptates nulla deleniti pariatur vitae vel eos sit asperiores aliquid,Lorem
ipsum dolor sit amet, at assum perpetua dissentiet sit, et sea probatus sententiae ullamcorper, voluptatibus signiferumque ex has. No vetua dissentiet sit, et sea probatus sententiae ullamcorper, voluptatibus signiferumque ex has. No vetua dissentiet
sit, et sea probatus sententiae ullamcorper, voluptatibus signiferumque ex has. No v molestiae recusandae placeat corporis earum assumenda dolorem! Earum necessitatibus tempora enim nisi officiis in. Ducimus illo placeat eveniet.</p>
</div>
</div>
</div>
I am new to web components.
I am trying to create a web component that looks like a "drop down / select".
when the element is closed but visible (not expanded) I would like it to be presented on the screen in the regular flow of the web page. Under it is some text that is not part of the control.
When the control is expanded, The expanded part should cover (go above) the text that is displayed under the control.
In practice the text is being pushed down.
Changing the control's css places the visual part over the text that should be below it.
I would appreciate ideas how to address the issue of creating a control that one part of it should be in the "flow" of the web page and the other part should "float" above the web page and located in relation to the visual part.
The following code is the web component: drop-down.html
<template id="drop-down">
<style>
.row {
z-index: 5;
position:relative;
background-color: white;
}
.drop-down {
z-index: 5;
position: relative;
background-color: red;
}
</style>
<div class="drop-down">
<div class="row">
<button onclick="addListElement(this);">+</button>
<input type="text" placeholder="Enter List Item">
</div>
</div>
</template>
<template id="list-item">
<div class="row">
<button onclick="addListElement(this);">+</button>
<input type="text" placeholder="Enter List Item">
</div>
</template>
<script>
let ddTemplate = document.currentScript.ownerDocument.querySelector('#drop-down');
let liTemplate = document.currentScript.ownerDocument.querySelector('#list-item');
customElements.define('drop-down', class extends HTMLElement {
constructor() {
super(); // always call super() first in the ctor.
let shadowRoot = this.attachShadow( {mode: 'open'} );
shadowRoot.appendChild( ddTemplate.content.cloneNode( true ));
}
});
function addListElement( el ) {
var parent = el.parentNode;
parent.parentNode.appendChild(liTemplate.content.cloneNode(true));
}
</script>
The html that tests it is the following: testDropDown.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test Drop-Down</title>
<link rel="import" href="./drop-down/drop-down.html">
</head>
<body>
<drop-down>My Drop Down</drop-down>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do<br/>
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim<br/>
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut<br/>
aliquip ex ea commodo consequat. Duis aute irure dolor in<br/>
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla<br/>
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in<br/>
culpa qui officia deserunt mollit anim id est laborum."
</p>
</body>
</html>
I would try to make the image align with the border line. But I cannot figure out. (As the image below) And I am not sure why the well is not covering my content. Not sure what is the problem. Hope you can help.
Any help will be appreciated!
.img-responsive {
left: 15px;
z-index: 14;
position: absolute;
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript" ></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js" type="text/javascript" ></script>
<div class="container">
<div class="row">
<div class="well">
<div class="col-md-6">
<img class="img-responsive" src="https://dummyimage.com/300x200/000/fff">
</div>
<div class="col-md-6">
<p>arbitror cernantur amet multos ullamco dolore ad philosophari a ad est arbitrantur qui distinguantur illum graviterque laboris quis quorum non quid consectetur doctrina instituendarum esse sempiternum ad ad coniunctione possumus a ingeniis sint irure illum</p>
</div>
</div>
</div>
</div>
I think this little correction does the work
<div class="container">
<div class="well">
<div class="row">
<div class="col-md-6">
<img class="img-responsive" src="https://dummyimage.com/300x200/000/fff">
</div>
<div class="col-md-6">
<p>arbitror cernantur amet multos ullamco dolore ad philosophari a ad est arbitrantur qui distinguantur illum graviterque laboris quis quorum non quid consectetur doctrina instituendarum esse sempiternum ad ad coniunctione possumus a ingeniis sint irure illum</p>
</div>
</div>
</div>
</div>
and why are you using this css ?
.img-responsive {
left: 15px;
z-index: 14;
position: absolute;
}
I added some little changes as per your comment
add this to your css
<style>
.div-img-padLftZero{
padding-left:0px;
}
</style>
then make your code like this
<div class="container">
<div class="well">
<div class="row">
<div class="col-md-6 div-img-padLftZero">
<img class="img-responsive" src="https://dummyimage.com/300x200/000/fff">
</div>
<div class="col-md-6">
<p>arbitror cernantur amet multos ullamco dolore ad philosophari a ad est arbitrantur qui distinguantur illum graviterque laboris quis quorum non quid consectetur doctrina instituendarum esse sempiternum ad ad coniunctione possumus a ingeniis sint irure illum</p>
</div>
</div>
</div>
</div>
Now it is left aligned as you desired
I am trying to create a simple slideshow with Jquery but I am messing up my height attribute for the container. I need the height to be "auto" because I would like to keep the aspect ratio stable when resizing. here is an example of my code, thanks!
<!DOCTYPE html>
<html lang="en-US" dir="ltr"
<head>
<meta charset="UTF-8">
<title>test</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=3.4.1"></script>
<script type="text/javascript">
var jq = jQuery.noConflict();
var i = 0;
var slides = ["#slide_2", "#slide_1"];
var imgSrc = new Array(2);
imgSrc[0] = "banner1.png"
imgSrc[1] = "banner2.png"
jq(document).ready(slideShow);
function slideShow(){
slides.reverse();
jq(slides[0]).attr("src", imgSrc[i]);
jq(slides[0]).fadeIn(1000);
jq(slides[1]).fadeOut(1000);
setTimeout("slideShow()", 5000);
i = (++i >= imgSrc.length)? 0: i;
}
</script>
<style type="text/css">
.slide {
position:absolute;
}
</style>
</head>
<body style="background:#a9a9a9;">
<headder id="branding" role="banner" style="display:block; background:#d0d0d0; width:100%; height:auto;">
<h1>Example</h1>
<div id="slideshow">
<img id="slide_1" class="slide" src="banner1.png"/>
<img id="slide_2" class="slide"/>
</div> <!-- #slideshow -->
</headder>
<div id="main">
<p>Lorem ipsum eu usu assum liberavisse, ut munere praesent complectitur mea. Sit an option maiorum principes. Ne per probo magna idque, est veniam exerci appareat no. Sit at amet propriae intellegebat, natum iusto forensibus duo ut. Pro hinc aperiri fabulas ut, probo tractatos euripidis an vis, ignota oblique ut nec. Ad ius munere soluta deterruisset, quot veri id vim, te vel bonorum ornatus persequeris. Pro hinc aperiri fabulas ut, probo tractatos euripidis an vis, ignota oblique ut nec. Ad ius munere soluta deterruisset, quot veri id vim, te vel bonorum ornatus persequeris.</p>
</div> <!-- #main -->
<footer id="last" role="contentinfo" style="background:#3c3c3c;">
<p style="color:#f9f8f0;">test site</p>
</footer>
</body>
</html>
thanks for your responses!
In my case what finally worked was to wrap all my images over another empty jpg(700bytes) image with the same resolution as my slides and position:relative.. it's faster and lighter than javascript, scales with the window and is totally respectful to the "flow" of the document.
note: to create an empty jpg with custom dimension you can find the 0xFFC0 marker in the header. The 3nd and 4rd byte after it is the y dimension and the 5rth and 6th is the x.
Cheers ;)
Here you can wrap all your images with a div or any tag and apply some fixed height to that div. in this way it will not affect aspect ratio of your image