I followed the teleport example(youtube video) and want to set the component to the fullscreen.
However, the header and footer still show up when the component is teleported to body or #q-app.
The only difference between my code and the example code is I use quasar layout. Not sure if that matters.
here is my layout code:
<template>
<q-layout view="hhh lpr fff">
<q-header class="bg-white text-black" bordered reveal>
...
</q-header>
<q-page-container class="bg-grey-2">
<router-view />
</q-page-container>
<q-footer class="bg-white text-black bordered reveal>
....
</q-footer>
</template>
here is my component
<template>
<teleport to="#q-app">
<div class="modal">
<h1>This is a modal</h1>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Beatae ipsa
laboriosam vero natus ut rerum quaerat, saepe praesentium tempore et hic
velit odio nemo minus labore quam ullam quod architecto?
</p>
</div>
</teleport>
</template>
<script setup lang="ts"></script>
<style lang="scss">
.modal {
background: beige;
padding: 10px;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 1;
}
</style>
You need to set up in CSS z-index higher than your header and footer components. For example z-index: 100;.
Related
I've got a relatively long phrase that consumes way too much space on mobile devices. It looks something like this:
.artificial-phone-viewport {
width: 320px;
height: 500px;
border: 1px solid darkgrey;
}
.container {
width: 100%;
height: 100%;
}
.text {
/*
* Don't want to change font-size, because text
* sometimes maybe shorter and 2.2rem is perfect
* for phrases that are not as long
*/
font-size: 2.2rem;
}
<body class="artificial-phone-viewport">
<div class="container">
<div class="text">
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Temporibus saepe illum a magni sequi error fugit dolore neque voluptates in laborum.
</div>
</div>
</body>
What I want is to make this text span at most, let's say, 10rem height. If it can't fit into 10rem of height, it should instead expand horizontally, maybe, overflowing its parent, maybe like this:
.artificial-phone-viewport {
width: 320px;
height: 500px;
border: 1px solid darkgrey;
}
.text {
font-size: 2.2rem;
white-space: nowrap;
}
<body class="artificial-phone-viewport">
<!-- Deleted container to reduce code, it actually
doesn't matter, because it anyway spans
100% width and height of its parent -->
<div class="text">
Lorem ipsum dolor, sit amet consectetur<br/>
adipisicing elit. Temporibus saepe illum<br/>
a magni sequi error fugit dolore neque<br/>
voluptates in laborum.
</div>
</body>
P.S. This snippet is just an example of what I want to see, I don't want any of these <br/>s or white-space: nowrap. Also I want the text to overflow its parent, because I then can use Javascript to scale it propertly, but it is not very relevant for the question, I suppose.
So I figured out a way to do it with Javascript, although I don't like it too much. I just increased the width of the element, until the height was small enough, like this
const text = document.querySelector('.text')
const rem = parseFloat(
getComputedStyle(document.documentElement).fontSize
)
let width = text.clientWidth / rem
while(text.clientWidth > 10*rem) {
width++
text.style.width = `${width}rem`
}
.artificial-phone-viewport {
width: 320px;
height: 500px;
border: 1px solid darkgrey;
}
.text {
font-size: 2.2rem;
}
<body class="artificial-phone-viewport">
<div class="text">
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Temporibus saepe illum a magni sequi error fugit dolore neque voluptates in laborum.
</div>
</body>
It's not very nice, but it works for me. If someone finds a way to do it without javascript, I'm open to other solutions
I've created the following:
And I'd like the top section 'independent' to be over to the right like the 'interactive' section. I've tried to float: right; but that's not correct.
My code is:
.badgesblock{style: 'padding-left: 30px;'}
.independent
= image_tag 'independent.png', style: 'float:left;'
.independentcopy{style: ''}
%p{style: 'font-weight: bold;'} Independent
%p{style: 'width: 450px;'} We’re the only independent user review site for wedding suppliers. Businesses can’t vet reviews on their listing – that’s why your customers trust us.
%br
%br
.verified
= image_tag 'verified.png', style: 'float:right;'
%p{style: 'font-weight: bold;'} Verified
%p{style: 'width: 450px;'} All reviews and reviewers are verified. Each user fills in their personal details and verifies their profile with a wedding date and a picture. The result is an authentic, trustworthy review system.
%br
%br
.interactive
= image_tag 'interactive.png', style: 'float:left;'
.interactivecopy{style: 'float:right;'}
%p{style: 'font-weight: bold;'} Interactive
%p{style: 'width: 450px;'} Passive display advertising has limited impact. We provide a unique opportunity to actively engage with potential customers and showcase the great service at the heart of your business.
What am I missing in the CSS?
This is a pretty clear cut case for a piece of reusable CSS called the media object.
Its a basic building block with an image, video or whatever and associated text on the left or right.
/** Generic media object **/
.media {
overflow: hidden;
}
.media-item {
float: left;
margin-right: 25px;
}
.media.flipped > .media-item {
margin-right: 0;
margin-left: 25px;
float: right;
}
/** specific styles **/
.badge {
/* ... */
}
<div class="badgesblock">
<div class="media badge independent">
<a href="#" class="media-item">
<img src="http://placehold.it/250x150"/>
</a>
<div class="media-body">
<p><strong>Independent</strong></p>
<p>We’re the only independent user review site for wedding suppliers. Businesses can’t vet reviews on their listing – that’s why your customers trust us.</p>
</div>
</div>
<div class="media badge flipped verified">
<a href="#" class="media-item">
<img src="http://placehold.it/250x150" />
</a>
<div class="media-body">
<p><strong>Verified</strong></p>
<p>All reviews and reviewers are verified. Each user fills in their personal details and verifies their profile with a wedding date and a picture. The result is an authentic, trustworthy review system.</p>
</div>
</div>
<div class="media badge interactive">
<a href="#" class="media-item">
<img src="http://placehold.it/250x150" />
</a>
<div class="media-body">
<p><strong>Interactive</strong></p>
<p>Passive display advertising has limited impact. We provide a unique opportunity to actively engage with potential customers and showcase the great service at the heart of your business.</p>
</div>
</div>
<div>
h2, p {
margin: 0;
}
.section {
border: 1px solid red;
display: inline-block;
width: 100%;
}
.section:nth-child(odd) img {
float: left;
margin-right: 15px;
}
.section:nth-child(even) img {
float: right;
margin-left: 15px;
}
<div class="badgesblock">
<div class="section independent">
<img src="http://placehold.it/100x100" />
<div class="independentCopy">
<h2>Independent</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae mollitia voluptates est, porro dolor suscipit perspiciatis asperiores, dolorum dicta vel sunt, cupiditate, animi reiciendis quis similique fugiat. Vel, ut, dolore.</p>
</div>
</div>
<div class="section verified">
<img src="http://placehold.it/100x100" />
<div class="verifiedCopy">
<h2>Verified</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae mollitia voluptates est, porro dolor suscipit perspiciatis asperiores, dolorum dicta vel sunt, cupiditate, animi reiciendis quis similique fugiat. Vel, ut, dolore.</p>
</div>
</div>
<div class="section interactive">
<img src="http://placehold.it/100x100" />
<div class="interactiveCopy">
<h2>Interactive</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae mollitia voluptates est, porro dolor suscipit perspiciatis asperiores, dolorum dicta vel sunt, cupiditate, animi reiciendis quis similique fugiat. Vel, ut, dolore.</p>
</div>
</div>
</div>
You don't have to do it like I did. I'm using some new (to you) css selectors like nth-child which makes it easier for me. But if you want to target by class or whatever, feel free. I just gave you an idea of what kind of css you need to achieve what you want.
Think of .section:nth-child(odd) like:
.section.independent img,
.section.interactive img { }
http://codepen.io/pacMakaveli/pen/jPEegN
I've spent a lot of time trying to figure out how I can create a layout similar to this, where the pages content is constrained by the container element's width, but the column on the left has a background that stretches to the far left of the user's screen (the yellow one in the example).
I'm trying to do this with Bootstrap, but it seems impossible as the container element contains the content of the page and also it's background.
Here is the JSFiddle for what I have so far.
Some sample code of the structure:
<div class="row">
<div class="container">
<div class="col-xs-6 left-one">
This one's background needs to stretch to the far left, on large screens.
</div>
<div class="col-xs-6 right-one">
This one's background can be that of the body
</div>
</div>
</div>
<div class="some-content">
<div class="container">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dignissimos minima laudantium, id a, porro aliquid expedita. Iste beatae provident architecto dolorum aspernatur maiores, ratione deserunt nesciunt magni unde repudiandae eaque.
</div>
</div>
Would really appreciate if someone can solve this mystery for me.
Here's the full code:
#import url('http://getbootstrap.com/dist/css/bootstrap.css');
body{
background: #eee;
}
.left-one{
background: yellow;
height: 500px;
padding-top: 20px;
}
.right-one{
background: #eee;
height: 500px;
padding-top: 20px;
}
.some-content{
background: lightslategray;
padding: 20px 0;
}
<script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.1.0/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<div class="row">
<div class="container">
<div class="col-xs-6 left-one">
This one's background needs to stretch to the far left, on large screens.
</div>
<div class="col-xs-6 right-one">
This one's background can be that of the body
</div>
</div>
</div>
<div class="some-content">
<div class="container">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dignissimos minima laudantium, id a, porro aliquid expedita. Iste beatae provident architecto dolorum aspernatur maiores, ratione deserunt nesciunt magni unde repudiandae eaque.
</div>
</div>
Just do what the guy have done in example & use the before element.
DEMO
CSS:
.left-one:before{
background: yellow;
bottom: 0;
content: "";
position: absolute;
right: 100%;
top: 0;
width: 9999px;
}
Basically want I want is for my large image to be to the left of my two small images, and I want my two small images to be stacked on top of one another. Currently I'm running the class "small-images" with a width of 30% because it makes them stack like I want, but I feel there is a better way to do this. Also these three images are going to run next to some text which is why I have all of them in one big div together so I can float them to the right of the main text. I don't mind if you take my code apart I'm trying to find the most efficient way possible and I'm using HTML5 and CSS3.
HTML5
<div class="images">
<div class="large-image">
<!--This is a larger image-->
<img alt="bussiness lage picture" src="Images/buisness-big.jpg">
<div class="small-image">
<!--These are two smaller images-->
<img alt="bussiness lage picture" src="Images/handshake.jpg">
<img alt="bussiness lage picture" src="Images/calculator.jpg">
</div>
</div>
</div>
CSS 3
/*This deals with the main images right of the main content*/
.images {
float: left;
margin-top: 3%;
}
.large-image {
float: left;
margin-left: 10%;
}
.small-image {
width: 30%;
float: right;
}
You can use this kind of structure :
.images {
float: left;
margin-right: 10px;
}
.images img {
float: left;
}
.images .thumbs {
float: left;
margin-left: 10px;
}
.images .thumbs img {
clear: both;
margin-bottom: 10px;
}
<article>
<aside class="images">
<img src="http://placehold.it/300/2ecc71/fff"/>
<div class="thumbs">
<img src="http://placehold.it/145/3498db/fff"/>
<img src="http://placehold.it/145/e74c3c/fff"/>
</div>
</aside>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corporis suscipit dolorum repellat eveniet error a aliquam magni laudantium pariatur adipisci quisquam nesciunt unde quo. Quae ab explicabo et iure minus id ad placeat ducimus eos delectus assumenda recusandae labore! Minus modi error. Illo mollitia consequuntur ipsam fugit voluptatibus eos repudiandae!
</article>
I want to vertically align a span after a floated image.
I searched for it in stack overflow and find this post. but my image is floated.
<div>
<img style="width:30px;height:30px; float:left">
<span style="vertical-align:middle">Doesn't work.</span>
</div>
I give vertical-align:middle to image and nothing change!
Thanks
Even though this is an extremely old post, you can achieve this using Flexbox:
div {
display: flex;
align-items: center;
}
<div>
<img style="width:30px;height:30px;" src="http://lorempixel.com/output/abstract-q-c-640-480-8.jpg" />
<span>Doesn't work.</span>
</div>
JsFiddle example
First remove float from it. Write like this:
<img style="width:30px;height:30px;vertical-align:middle" src="http://lorempixel.com/output/abstract-q-c-640-480-8.jpg">
<span>Doesn't work.</span>
Check this http://jsfiddle.net/ws3Uf/
Add line-height (equal to picture height):
<div>
<img style="width:30px;height:30px; float:left">
<span style="vertical-align:middle; line-height: 30px;">Works!</span>
</div>
See example.
You can manually change as well
<div>
<img style="width:30px;height:30px float:left">
<span style="float:left;padding-top:15px;">Will work.</span>
</div>
Demo
Or you can use a table
A <span> is an inline element, try adding display:block to the span, give it the same height as the image and a line height to match. Float it left as well. That should work
You could do the following:
div:after {
content:"";
clear:both;
display:block;
}
float the picture
set a height to picture.
put a div1>div2>text after the picture.
set div1 the same height as the picture.
set div2 position relative, top 0 and transform translateY -50.
https://codepen.io/aungthihaaung/pen/ExXGvGy
.picture {
height: 300px;
float: left;
}
.div1 {
height: 300px;
}
.div2 {
position: relative;
top: 50%;
transform: translateY(-50%);
}
<img src="https://via.placeholder.com/300" class="picture" />
<div class="div1">
<div class="div2">
<h1>Hi There!</h1>
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Et, deleniti
perferendis! Ut, eaque iste incidunt atque perferendis odio laborum
nobis obcaecati exercitationem molestiae nihil est recusandae
mollitia. Fuga beatae inventore, adipisci ipsa aliquid corporis harum
ex tenetur iure assumenda optio quod eaque omnis porro ab consequuntur
unde a totam minima.
</div>
</div>