Dual videos to stack on mobile - html

I am working on a shopify page and customized the video section template to post dual videos. So I was able to create the two videos side by side but when I display them on my phone it displays the video side by side instead of being stacked. below is a snipet of the code. If yall need the all the text I can send it. I made it short for space. I would like to thank you for y'alls help in advance.
I am assuming that the changes will need to be done in css, but I not sure how to format the #media tag.
<!-- Beginning first video -->
<div class="mvideo-layout">
<div class="video-container">
<div id="multiple-left" class="video-item--multiple" data-action="play-video">
<div class="video-wrapper">
<div class="video-wrapper__image-wrapper">
{%- if section.settings.image -%}
{%- capture supported_sizes -%}{%- render 'image-size', sizes:
'300,400,500,600,700,800,900,1000,1200', image:
section.settings.image -%}{%- endcapture -%}
{%- assign image_url = section.settings.image | img_url: '1x1' |
replace: '_1x1.', '_{width}x.' -%}
This begins the next video on the side
<!-- Beginning second video -->
<div id="multiple-right" class="video-item" data-action="play-video">
<div class="video-wrapper">
<div class="video-wrapper__image-wrapper">
{%- if section.settings.image2 -%}
{%- capture supported_sizes -%}{%- render 'image-size', sizes:
'300,400,500,600,700,800,900,1000,1200', image:
section.settings.image2 -%}{%- endcapture -%}
{%- assign image_url = section.settings.image2 | img_url: '1x1' |
replace: '_1x1.', '_{width}x.' -%}
Here is the CSS code
.mvideo-layout{
max-width: auto;
}
.video-container{
position: relative;
padding-bottom: auto;
}
#multiple-left{
float: left;
padding: 5px;
width: 47.5%;
box-sizing: border-box;
}
#multiple-right{
float: left;
padding: 10px;
width: 47.5%;
box-sizing: border-box;

Everyone after a little more research I found my answer. I add the following to my CSS file.
#media (max-width:767px) {
.video-container {
width: 100%;
height: auto;
}
#multiple-left {
width: 100%;
height: auto;
float: none;
}
#multiple-right {
width: 100%;
height: auto;
float: none;
}
}

Related

css only solution to hide element when page content is less than or equal to 110vh or an equivalent solution

I have implemented a css only back to top button, but on shorter pages it shows when it is not needed.
.top {
position: sticky;
bottom: 9px;
padding: 9px;
place-self: end;
margin-top: 109vh;
font-weight:700;
border-radius: 9px;
color: var(--a1);
background: var(--c2);
}
.top:hover {
color: var(--c2);
background: var(--a1);
text-decoration: none;
}
You can see it in the bottom left corner here: https://abridge.netlify.app/overview-abridge/ (don't need to see it when the page is this short)
It works fine so long as its a longer page: https://abridge.netlify.app/overview-code-blocks/
I have thought of artificially increasing the size of short pages, but that just seems kinda hacky, also I know I can easily resolve this with javascript, but I am trying to find a solution that does not rely on javascript. I tried playing around with media queries but could not find any that actually query how much content is in a viewport.
If you are familiar with zola, the repo is here: https://github.com/Jieiku/abridge
If you have zola installed you can clone the repository and run zola serve from the directory, to test changes locally.
Here is the file with the back to top: https://github.com/Jieiku/abridge/blob/master/sass/include/_top.scss
EDIT: for the moment I have discovered a creative way of resolving this, because its a SSG and zola has readtime value I did this:
{%- block gotop %}
{%- if page.reading_time %}
{%- if page.reading_time > 1 %}
&cuwed;
{%- endif %}
{%- endif %}
{%- endblock gotop %}
The only thing to resolve now is to somehow get it over on the right side of the page instead of the left side.
This is the solution I used:
.topout {
position: sticky;
bottom: 1px;
padding: 20px;
place-self: end;
margin-top: 110vh;
pointer-events: none;
}
.topleft {
margin-left: calc(100% - 80px);
}
.top {
pointer-events: all;
padding: 9px;
border-radius: 9px;
font-weight:700;
color: #FF9900;
background: #222222;
}
.top:hover {
text-decoration: none;
color: #222222;
background: #FF9900;
}
Then in Zola Template page:
{%- block gotop %}
{%- if page.reading_time %}
{%- if page.reading_time > 1 %}
<span class="topout">
<span class="topleft"> </span>&cuwed;
</span>
{%- endif %}
{%- endif %}
{%- endblock gotop %}
You can see it here: https://abridge.netlify.app/overview-code-blocks/
I would have liked to avoid using calc() however this does work without issue in: Firefox, Chrome, Android Chrome
I think the cleanest solution would be to utilize #media screen and (max-height: 110vh)
Here is my suggestion:
#media screen and (max-height: 110vh){
.top{
display:none;
}
}
The idea here is that if the page's viewport is currently within that max-height of 110vh then we want to set .top to no longer display on the page.

Django templates not rendering CSS when template variables are used

I am trying to build a paywall using HTML and CSS in Django, but somehow the CSS that is supposed to fade portions of the text does not render. Here is what I have:
<style>
.adjust-image {
display: block;
width: auto;
max-width: 100%;
max-height: 1000px;
}
.blur-text {
filter: blur(5px);
user-select: none;
pointer-events: none;
}
.fade-out {
user-select: none;
position: relative;
}
.fade-out:after {
content: "";
height: 75%;
width: 100%;
position: absolute;
bottom: 0;
left: 0;
background: linear-gradient(to bottom, rgba(255,255,255,0), #fff);
}
#paywall-wrapper {
padding: 35px;
border-radius: 5px;
position: relative;
margin-bottom: 30px;
box-shadow: 0px 0px 20px -1px rgba(0,0,0,0.20);
}
#paywall-wrapper * {
text-align: center;
}
#paywall-wrapper .btn {
left: 50%;
transform: translateX(-50%);
position: relative;
}
</style>
<div class="display-margins">
<div>
<h5>{{solution.questionToProblem}}</h5>
<h6><b>Solution</b></h6>
{% if request.user.is_anonymous or solution.free != True and request.user.is_subscriber != True %}
<p class= "format-paragraph fade-out:after">{{solution.solutionToProblem|safe}}</p>
<div id="paywall-wrapper">
<h4>Premium Subscription</h4>
<p>To view this solution, get our subscription for just <strong>$17</strong>.</p>
<a class="btn btn-primary text-light" href = "{% url 'subscribe' %}">Subscribe</a>
</div>
{% else %}
<p class="noselect format-paragraph">{{solution.solutionToProblem|safe}}</p>
{% for s in solution_images %}
<img class = "adjust-image noselect" src="{{ s.photo.url }}">
<br></br>
{% endfor %}
{% endif %}
{% render_comments solution request %}
<br class= "extra_spacing"></br>
</div>
</div>
Ideally, the text for paywall is supposed to fade out like this:
But it doesn't render when I have template variables in my <p> tags:
Surprisingly enough, if I type out content in my <p> tags manually, it works. But when I use <p>{{random content}}</p>, it doesn't work.
What am I doing wrong with my CSS or my HTML when I say <p class= "format-paragraph fade-out:after">{{solution.solutionToProblem|safe}}</p>?
Make sure when you want CSS integrated in Django, and you have HTML in your template variable, use:
{{put_your_template_variable|striptags}}
instead of safe.

How can I add animations to my images in my Django app?

I´m trying to add a kind of animation to some images in my Django app, what I want to do is that when the user moves the mouse around the image it gets bigger.
I tried adding some code in my CSS but the image won't change
Thank you for your help.
My index.html
{%block contenido %}
<div id="container" class="foto_pelicula">
{% for p in peliculas %}
{% if p.genero.id == 1 %}
<img src={{p.urlPortada}} width="289" height="289"/></li>
{% endif %}
{% endfor %}
</div>
<div id="container" class="foto_pelicula">
{% for p in peliculas %}
{% if p.genero.id == 2 %}
<img src={{p.urlPortada}} width="289" height="289"/></li>
{% endif %}
{% endfor %}
</div>
<div id="container" class="foto_pelicula">
{% for p in peliculas %}
{% if p.genero.id == 3 %}
<img src={{p.urlPortada}} width="289" height="289"/></li>
{% endif %}
{% endfor %}
</div>
{% endblock %}
The Images SRCs are urls that I take from the internet, I guess it does not really matter whether they are taken from the internet or stored in your proyect.
my CSS
#container{
width: 290px;
overflow: hidden;
margin: 5px 4px 0 auto;
padding: 0;
background: #222; /* FONDO DEL RECTANGULO CONTENEDOR */
border: 3px solid #8E1600;
float: left;
}
I added this new lines to my CSS but the image won't change.
.foto_pelicula > img:hover {
transform: scale(1.1);
}
Maybe I'm not using the proper lines in the CSS as I'm a junior programmer.
Help is much appreciated
This question has no connection to Django. In future try to create working html template for your purposes and then add it to django template.
You setup .foto_pelicula > img:hover to transform image. But > selector finds only direct child. See documentation on selectors.
And in your code direct child is a, but not img. Therefore you don't see result. You can change your css rule to .foto_pelicula > a > img:hover
See demo:
#container{
width: 290px;
overflow: hidden;
margin: 5px 4px 0 auto;
padding: 0;
background: #222; /* FONDO DEL RECTANGULO CONTENEDOR */
border: 3px solid #8E1600;
float: left;
}
.foto_pelicula > a > img:hover {
transform: scale(1.1);
}
<div id="container" class="foto_pelicula">
<img src="https://via.placeholder.com/289" width="289" height="289"/>
</div>
IMPORTANT
In your html code I see several divs with id="container". You can setup only one id with certain name to each page. That's why it called identifier.
So change your ids to classes or give different id names for this divs.

Add Hover Feature On Product Image

I am trying to add a feature to show an alternative product picture when the cursor hovers over the product image in a collection view.
Whenever I view the page with the code below, the product images have shifted to the bottom of the container and also cover the Title/Price that was below them.
What can I correct to keep the pictures in their original alignment and have only the hover effect work?
Thank you!
Here is what I currently have in product-card-grid.liquid --
<div id="{{ wrapper_id }}" class="grid-view-item__image-wrapper js">
<div style="padding-top:{% unless product.featured_image == blank %}{{ 1 | divided_by: product.featured_image.aspect_ratio | times: 100}}%{% else %}100%{% endunless %};">
<div class="reveal">
<img id="{{ img_id }}"
class="grid-view-item__image lazyload"
src="{{ product.featured_image | img_url: '300x300' }}"
data-src="{{ img_url }}"
data-widths="[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048]"
data-aspectratio="{{ product.featured_image.aspect_ratio }}"
data-sizes="auto"
alt="">
<img id="{{img_id}}"
class="hidden"
src="{{ product.images.last }}"
data-src="{{ img_url }} "
data-widths="[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048]"
data-aspectratio="{{ product.featured_image.aspect_ratio }}"
data-sizes="auto"
alt="{{ product.images.last.alt | escape }}">
</div>
</div>
</div>
The css for "Reveal" is below:
/* ===============================================
// Reveal module
// =============================================== */
.reveal .hidden { display: block !important; visibility: visible !important;}
.product:hover .reveal img { opacity: 1; }
.reveal { position: relative; }
.reveal .hidden {
position: absolute;
z-index: -1;
top: 0;
width: 100%;
height: 100%;
opacity: 0;
-webkit-transition: opacity 0.3s ease-in-out;
-moz-transition: opacity 0.3s ease-in-out;
-o-transition: opacity 0.3s ease-in-out;
transition: opacity 0.3s ease-in-out;
}
.reveal:hover .hidden {
z-index: 100000;
opacity: 1;
}
.reveal .caption {
position: absolute;
top: 0;
display: table;
width: 100%;
height: 100%;
background-color: white; /* fallback for IE8 */
background-color: rgba(255, 255, 255, 0.7);
font: 13px/1.6 sans-serif;
text-transform: uppercase;
color: #333;
letter-spacing: 1px;
text-align: center;
text-rendering: optimizeLegibility;
}
.reveal .hidden .caption .centered {
display: table-cell;
vertical-align: middle;
}
#media (min-width: 480px) and (max-width: 979px) {
.reveal .caption {
font-size: 11px;
}
}
There's a lot going on in your CSS, but if I understand the sitaution correctly you want to achieve an effect like the one in this Codepen, right?
In your CSS, absolutely position two images inside of a div (with top: 0px and left: 0px) and change the opacity of the top image in the stack by hovering on the parent.
HTML:
<div class='reveal'>
<img src='image_src' class='bottom'>
<img src='image_src' class='top'>
</div>
CSS:
.top, .bottom {
position: absolute;
opacity: 1;
top: 0px;
left: 0px;
}
.frame:hover .top {
opacity: 0;
}
EDIT: Implementation w/ grid, as requested.
HTML:
<div class='grid'>
<div class='reveal'>
<img src='image_src' class='bottom'>
<img src='image_src' class='top'>
</div>
<div class='reveal'>
<img src='image_src' class='bottom'>
<img src='image_src' class='top'>
</div>
</div>
CSS:
.grid {
display: flex;
flex-wrap: wrap; /*makes the grid "responsive"*/
}
.reveal {
display: flex;
flex: 1 1 200px; /*last value must be picture width*/
height:200px; /* picture height*/
margin: 20px; /*aesthetic only*/
position: relative;
}
.top, .bottom {
position: absolute;
opacity: 1;
top: 0px;
left: 50%; /*centers pictures inside flex children (.reveal divs)*/
transform: translate(-50%, 0); /*see above*/
}
.reveal:hover .top {
opacity: 0;
}
Demo on Codepen
The above example uses flexbox to create a simple grid which will work with the (slightly modified) .reveal divs from my original post. If you're unfamiliar with flexbox syntax, there's an awesome free video course from Wes Bos that I highly recommend.
P.S. Note that the grid will only work "out of the box" if the images have a set pixel width, although you could easily support different images sizes with a little media query magic.
Got it to work with the following
In the CSS, I had the #media (hover:hover){} so that users do not have to double click an image on mobile to go to the product page.
CSS:
/* ===============================================
// Reveal module
// =============================================== */
#media (hover:hover) {
.has-secondary.grid-view-item__link img.secondary{
display:none;
}
}
#media (hover:hover) {
.has-secondary.grid-view-item__link:hover img.secondary{
display:block;
}
}
#media (hover:hover) {
.has-secondary.grid-view-item__link:hover img.grid-view-item__image{
display:none;
}
}
#media screen and (min-width:767px){
.has-secondary.grid-view-item__link img.secondary{
display:none;
}
.has-secondary.grid-view-item__link:hover img.secondary{
display:block;
}
.has-secondary.grid-view-item__link:hover img.grid-view-item__image{
display:none;
}
}
#media screen and (max-width:767px){
.has-secondary.grid-view-item__link img.secondary{
display:none;
}
}
Changed product-card-grid.liquid HTML/Liquid to the following:
{% unless grid_image_width %}
{%- assign grid_image_width = '600x600' -%}
{% endunless %}
<div class="grid-view-item{% unless product.available %} product-price--sold-out grid-view-item--sold-out{% endunless %}">
<a class="grid-view-item__link {% if product.images.size > 1 %} has-secondary{% endif %}" href="{{ product.url | within: collection }}">
<img class="grid-view-item__image" src="{{ product.featured_image.src | img_url: grid_image_width }}" alt="{{ product.featured_image.alt }}">
{% if product.images.size > 1 %}
<img class="secondary" src="{{ product.images.last | img_url: grid_image_width }}" alt="{{ product.images.last.alt | escape }}">
{% endif %}
</a>
</div>
<div class="h4 grid-view-item__title">
{{ product.title }}
</div>
{% if section.settings.show_vendor %}
<div class="grid-view-item__vendor">{{ product.vendor }}</div>
{% endif %}
<div class="grid-view-item__meta">
{% include 'product-price', variant: product %}
</div>

django forms: styling widget when field is required or has an error

I'm creating a django form and I can't seem to access each field's widget to style it differently when there's an error or when the field is required (eg: highlight the field's box).
HTML:
{% block content %}
<form action="" method="POST" class="form"> {% csrf_token %}
{% for field in form %}
<div class="fields-container">
<p class="label">{{ field.label }}</p>
{{ field }}
</div>
{{ field.errors }}
{% endfor %}
<button type="submit" id="form-button">Submit</button>
</form>
{% endblock %}
CSS:
.label {
margin: 0 5px 0 0;
width: 20%;
text-align: left;
}
#id_full_name, #id_email, #id_message {
margin: 0;
flex: 1 1;
}
#id_message {
resize: none;
overflow: auto;
}
.errorlist { /*default css class for form errors*/
color: 999999;
font-size: 75%;
font-weight: bold;
list-style: none;
margin-bottom: 5px;
align-self: flex-start;
}
I've been accessing and styling the widgets using #id_fieldname, but I've tried the following and it didn't work:
#id_fieldname.required, id_fieldname.error { border: 2px solid red; }
Thanks in advance!
You could add a class 'required' in your container <div>:
<div class="fields-container {% if field.field.required %}required{% endif %}">
Using django form methods form.as_p, form.as_ul, form.as_table, this would be done automatically if you declare a specific css class for required fields in your Form, for example:
class myForm(forms.Form):
required_css_class = 'required'
...
More in documentation