I am trying to show a second image and text when you hover over an original image in Shopify. Now for some reason, when I hover, the second image expands and takes more space than the original (when both are the same size). I am attaching the CSS snippet.
The original container css:
.custom-content1{
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
width: 100%;
-ms-flex-align: center;
-webkit-align-items: stretch;
-moz-align-items: stretch;
-ms-align-items: stretch;
-o-align-items: stretch;
align-items: stretch;
-webkit-flex-wrap: wrap;
-moz-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
width: auto;
margin-bottom: -$gridGutter;
margin-left: -$gridGutter;}
hover css:
.reveal .hidden {
display: block !important; visibility: visible !important;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.image:hover .reveal img { opacity: 20%; }
.reveal { position: relative;
}
.reveal .hidden {
position: absolute;
z-index: -1;
top: 0;
width: 100%;
height: 100%;
text-align: center;
vertical-align: middle;
opacity: 100%;
-webkit-transition: opacity 0.1s ease-in-out;
-moz-transition: opacity 0.1s ease-in-out;
-o-transition: opacity 0.1s ease-in-out;
transition: opacity 0.1s ease-in-out;
}
.reveal:hover .hidden {
z-index: 100000;
opacity: 100%;
color: #ffff !important;
}
How can I make sure that on hover the image is taking up exactly the same space as the original image? Any help or pointers will be helpful. Thank you!
P.S adding the html and liquid portion to this:
<div class="custom-content1">
{%- assign max_height = '' -%}
{%- assign block_width = '' -%}
{%- assign block_width_mobile = '' -%}
{% for block in section.blocks %}
{% case block.settings.width %}
{% when '25%' %}
{%- assign max_height = 250 -%}
{%- assign block_width = 'medium-up--one-quarter' -%}
{%- assign block_width_mobile = 'small--one-whole' -%}
{% when '33%' %}
{%- assign max_height = 345 -%}
{%- assign block_width = 'medium-up--one-third' -%}
{%- assign block_width_mobile = 'small--one-whole' -%}
{% when '50%' %}
{%- assign max_height = 530 -%}
{%- assign block_width = 'medium-up--one-half' -%}
{%- assign block_width_mobile = 'small--one-whole' -%}
{% when '66%' %}
{%- assign max_height = 720 -%}
{%- assign block_width = 'medium-up--two-thirds' -%}
{%- assign block_width_mobile = 'small--one-whole' -%}
{% when '75%' %}
{%- assign max_height = 810 -%}
{%- assign block_width = 'medium-up--three-quarters' -%}
{%- assign block_width_mobile = 'small--one-whole' -%}
{% when '100%' %}
{%- assign max_height = 1290 -%}
{%- assign block_width = 'medium-up--one-whole' -%}
{%- assign block_width_mobile = 'small--one-whole' -%}
{% endcase %}
{% if block.type == 'image' %}
{% capture img_id %}CustomImage--{{ forloop.index }}-{{ block.settings.image.id }}{% endcapture %}
{% capture img_wrapper_id %}CustomImageWrapper--{{ forloop.index }}-{{ block.settings.image.id }}{% endcapture %}
{% unless block.settings.image == blank %}
{% include 'image-style', image: block.settings.image, height: max_height, wrapper_id: img_wrapper_id, img_id: img_id %}
{% endunless %}
{% endif %}
<div class="custom__item1 custom__item1--{{ block.type }} custom__item1--{{ block.id }} {{ block_width_mobile }} {{ block_width }}{% if block.settings.alignment %} align--{{ block.settings.alignment }}{% endif %}" {{ block.shopify_attributes }}>
<div class="custom__item1-inner custom__item1-inner--{{ block.type }}"{% if block.type == 'image' %} id="{{ img_wrapper_id }}"{% endif %}>
{% case block.type %}
{% when 'image' %}
{% if block.settings.image != blank %}
{% if block.settings.image_link != blank %}
<a href="{{block.settings.image_link}}">
<div class= "reveal">
{%- assign img_url = block.settings.image | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}
<!--<div style="padding-top:{{ 1 | divided_by: block.settings.image.aspect_ratio | times: 100}}%;" data-image-loading-animation>
</div>-->
<img id="{{ img_id }}"
class="custom__image1 lazyload js"
data-src="{{ img_url }}"
data-widths="[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048]"
data-aspectratio="{{ block.settings.image.aspect_ratio }}"
data-sizes="auto"
alt="{{ block.settings.image.alt | escape }}">
{%- assign img_url2 = block.settings.image_2 | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}
<img class="hidden custom__image1 lazyload js"
data-src="{{ img_url2 }}"
data-widths="[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048]"
data-aspectratio="{{ block.settings.image.aspect_ratio }}"
data-sizes="auto"
alt="{{ block.settings.image.alt | escape }}"/>
<div class="text-center medium1-up--text-{{ block.settings.align_text }} ">
{%- assign image_text = block.settings.image_text -%}
<h4 class="hidden h31 rte-setting rte1">{{image_text}}</h4>
</div>
<noscript>
{% capture image_size %}{{ max_height }}x{% endcapture %}
{{ block.settings.image | img_url: image_size, scale: 2, crop: 'top' | img_tag: block.settings.image.alt, 'custom__image' }}
</noscript>
{% else %}
{{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
{% endif %}
{% endif %}
</div>
</a>
{% when 'text' %}
<div class="medium-up--text-{{ block.settings.align_text }}">
{% if block.settings.title != blank %}
<h4 class="h3">{{ block.settings.title | escape }}</h4>
{% endif %}
{% if block.settings.text != blank %}
<div class="rte-setting rte1">{{ block.settings.text }}</div>
{% endif %}
</div>
{% endcase %}
</div>
</div>
{% endfor %}
</div>
Found the answer.I just removed height and width from .reveal .hidden {}.
Related
I'm creating a logo list for shopify theme and I wanted a marquee effect on the logos to be added, as logos are considered as blocks to add, it works but at the last block at the end of the for loop, the animation feels like it breaks and after few secs it shows back when for loop starts again, i'll attach a gif to show
here's the code
{% liquid
case section.blocks.size
when 3
assign keyframe = 900
assign width = 600
when 4
assign keyframe = 1200
assign width = 900
when 5
assign keyframe = 1500
assign width = 1200
when 6
assign keyframe = 1800
assign width = 1500
when 7
assign keyframe = 2100
assign width = 1800
when 8
assign keyframe = 2400
assign width = 2100
when 9
assign keyframe = 2700
assign width = 2400
when 10
assign keyframe = 3000
assign width = 2700
endcase %}
<style>
.logo_list--marquee {
display: flex;
overflow-x: hidden;
flex-wrap: nowrap;
white-space: nowrap;
min-width: 100%;
height: 200px;
}
.marquee--content {
display: flex;
flex-shrink: 0;
align-items: center;
width: {{ width }}px;
animation: slide-left {{ section.settings.marquee_speed }}s linear infinite;
}
#keyframes slide-left {
from {
transform: translateX(0);
}
to {
transform: translateX(-{{ keyframe }}px);
}
}
</style>
<div class="row logo_list--marquee">
<div class="marquee--content">
{% liquid
for block in section.blocks
<div class="col-md-4 col-sm-6 col-6 logo_list--logo">
{%- if link != blank -%}
<a href="{{ link }}">
{%- endif -%}
<div class="logo__img">
{%- if image != blank -%}
{{ image | image_url: width: 1500 | image_tag:
width: image.width,
height: image.height,
widths: '375, 550, 750, 1100, 1500, 1780, 2000, 3000, 3840',
alt: image.alt | escape }}
{%- else -%}
{{ 'logo' | placeholder_svg_tag: 'logo-list__placeholder' }}
{%- endif -%}
</div>
{%- if link != blank -%}
</a>
{%- endif -%}
</div>
endfor
if section.blocks.size >= 3 and section.settings.marquee
for block in section.blocks
if forloop.last == true
break
else
<div class="col-md-4 col-sm-6 col-6 logo_list--logo">
{%- if link != blank -%}
<a href="{{ link }}">
{%- endif -%}
<div class="logo__img">
{%- if image != blank -%}
{{ image | image_url: width: 1500 | image_tag:
width: image.width,
height: image.height,
widths: '375, 550, 750, 1100, 1500, 1780, 2000, 3000, 3840',
alt: image.alt | escape }}
{%- else -%}
{{ 'logo' | placeholder_svg_tag: 'logo-list__placeholder' }}
{%- endif -%}
</div>
{%- if link != blank -%}
</a>
{%- endif -%}
</div>
endif
endfor
endif %}
</div>
</div>
this is my code i want to give different colors to comments
like grey(#eee) to odd and blue (#e6f9ff) to even
here this line is giving me error
background-color: {{ bg_color }}
{% extends 'base.html' %}
{% block content %}
<h1>{% block title %} Comments {% endblock %}</h1>
<div style="width: 50%; margin: auto">
{% for comment in comments %}
{% if loop.index % 2 == 0 %}
{% set bg_color = '#e6f9ff' %}
{% else %}
{% set bg_color = '#eee' %}
{% endif %}
<div style="padding: 10px; background-color: {{ bg_color }}; margin: 20px">
<p>#{{ loop.index }}</p>
<p style="font-size: 24px">{{ comment }}</p>
</div>
{% endfor %}
</div>
{% endblock %}
I think jinja version is updated and my course which Im following is old
so anyone who knows to answer me
You should note the scope for the variables. If you define a variable within an if-else block, it is only valid there.
<div style="width: 50%; margin: auto">
{% for comment in comments -%}
{% set bg_color = '#e6f9ff' if loop.index % 2 == 0 else '#eee' %}
<div style="padding: 10px; background-color: {{ bg_color }}; margin: 20px">
<p>#{{ loop.index }}</p>
<p style="font-size: 24px">{{ comment }}</p>
</div>
{% endfor -%}
</div>
Instead of using jinja you can also use css to assign a different background color to every other line.
<div class="comments">
{% for comment in comments -%}
<div>
<p>#{{ loop.index }}</p>
<p class="text">{{ comment }}</p>
</div>
{% endfor -%}
</div>
<style type="text/css">
.comments {
width: 50%;
margin: auto;
}
.comments div {
padding: 10px;
background-color: #e6f9ff;
margin: 20px
}
.comments div:nth-child(odd) {
background-color: #eee;
}
.comments .text {
font-size: 24px
}
</style>
I am working on CS50 Project 2 and have a webpage that displays active listings. I want to add some changes to the css, but it nothing happens when I add changes to the style in the head, but inline styles work. How do I make it work in the head style?
{% extends "auctions/layout.html" %}
<head>
{% block style %}
<style>
.text {
font-size: 10%;
}
</style>
{% endblock %}
</head>
{% block body %}
<h2>Active Listings</h2>
{% for listing in listings %}
<img src ="{{ listing.image }}" style = "height: 10%; width: 10%;">
<h4 class = "text" style = "color: aqua;">{{ listing.title }}</h4>
<h6>Description: {{ listing.description }}</h6>
<h6>Category: {{ listing.category }}</h6>
<h6>Price: ${{ listing.bid }}</h6>
{% endfor %}
{% endblock %}
This is the code. The font size doesn't change, but it will change colors because of the inline style.
If I add the color style to the head style, not in the inline, nothing happens. This is that code.
<head>
{% block style %}
<style>
.text {
font-size: 50%;
font-family: fantasy;
color: aqua;
}
</style>
{% endblock %}
</head>
{% block body %}
<h2>Active Listings</h2>
{% for listing in listings %}
<img src ="{{ listing.image }}" style = "height: 10%; width: 10%;">
<h4 class = "text">{{ listing.title }}</h4>
<h6>Description: {{ listing.description }}</h6>
<h6>Category: {{ listing.category }}</h6>
<h6>Price: ${{ listing.bid }}</h6>
{% endfor %}
{% endblock %}
In this code the style does not change at all.
This is the html code that is rendered.
{% block body %}
<h2>Active Listings</h2>
{% for listing in listings %}
<img src ="{{ listing.image }}" style = "height: 10%; width: 10%;">
<h4 class = "text">{{ listing.title }}</h4>
<h6>Description: {{ listing.description }}</h6>
<h6>Category: {{ listing.category }}</h6>
<h6>Price: ${{ listing.bid }}</h6>
{% endfor %}
{% endblock %}
Because this is a Django template, you can link a stylesheet stored in a static file folder. This link is a video that explains how to do it.
I'm using Jekyll-Paginate-v2 and their Pagination Trails to create pagination for my blog. I have everything working but wanted to add some ellipses to indicate more pages. When you're on the first page, the last page should show at the end with ellipses in front, and after passing a certain number of pages, the first page should show with ellipses as well. If you get to the last page the ellipses should disappear.
Example:
< 1 2 3 4 5 6 7 8 8 10 ... 50 >
< 1... 5 6 7 8 9 10 ... 50>
Pagination w/ Trails
{% if paginator.total_pages > 1 %}
<div class="pagination">
{% if paginator.previous_page %}
<a href='{{ paginator.previous_page_path | prepend: site.baseurl }}' class='prev'>Previous</a>
{% endif %}
{% if paginator.page_trail %}
{% for trail in paginator.page_trail %}
<a href="{{ trail.path | prepend: site.baseurl | replace: '//', '/' | remove: "index.html" }}" class='{% if page.url == trail.path %}current{% endif %}'>{{ trail.num }}</a>
{% endfor %}
{% endif %}
{% if paginator.next_page %}
<a href='{{ paginator.next_page_path | prepend: site.baseurl }}' class='next'>Next</a>
{% endif %}
</div>
{% endif %}
You'll need to add some conditionals for where you want those ellipses. This is untested, but it might get you started:
<div class="pagination">
{% if paginator.total_pages > 1 %}
<ul>
{% if paginator.previous_page %}
<li><</li>
{% endif %}
{% for page in (1..paginator.total_pages) %}
{% assign last_five = forloop.length | minus: 4 %}
{% assign last_page = forloop.length %}
{% if forloop.length > 5 %}
{% if paginator.page <= 5 %}
{% if forloop.index <= 5 %}
{% if forloop.first and page == paginator.page %}
<li class="current-page"><span>{{ page }}</span></li>
{% elsif forloop.first %}
<li>1</li>
{% elsif page == paginator.page %}
<li class="current-page"><span>{{ page }}</span></li>
{% else %}
<li>{{ page }}</li>
{% endif %}
{% else %}
{% if paginator.page == 5 %}
<li>6</li>
{% endif %}
<li>…</li>
<li>{{ last_page }}</li>
{% break %}
{% endif %}
{% elsif paginator.page >= last_five %}
{% if forloop.index >= last_five %}
{% if forloop.index == last_five %}
<li>1</li>
<li>…</li>
{% if page == last_five %}
<li>{{ page | minus: 1 }}</li>
{% endif %}
{% if page == paginator.page %}
<li class="current-page"><span>{{ page }}</span></li>
{% else %}
<li>{{ page }}</li>
{% endif %}
{% elsif forloop.last and page == paginator.page %}
<li class="current-page"><span>{{ page }}</span></li>
{% elsif page == paginator.page %}
<li class="current-page"><span>{{ page }}</span></li>
{% else %}
<li>{{ page }}</li>
{% endif %}
{% endif %}
{% else %}
{% if forloop.first %}
<li>1</li>
{% endif %}
{% if forloop.index == paginator.page | minus: 2 %}
<li>…</li>
<li>{{ page | minus: 2 }}</li>
{% endif %}
{% if forloop.index == paginator.page | minus: 1 %}
<li>{{ page | minus: 1 }}</li>
{% endif %}
{% if page == paginator.page %}
<li class="current-page"><span>{{ page }}</span></li>
{% endif %}
{% if forloop.index == paginator.page | plus: 1 %}
<li>{{ page | plus: 1 }}</li>
{% endif %}
{% if forloop.index == paginator.page | plus: 2 %}
<li>{{ page | plus: 2 }}</li>
<li>…</li>
{% endif %}
{% if forloop.last %}
<li>{{ forloop.index }}</li>
{% endif %}
{% endif %}
{% else %}
{% if page == paginator.page %}
<li class="current-page"><span>{{ page }}</span></li>
{% elsif page == 1 %}
<li>{{ page }}</li>
{% else %}
<li>{{ page }}</li>
{% endif %}
{% endif %}
{% endfor %}
{% if paginator.next_page %}
<li>></li>
{% endif %}
</ul>
{% endif %}
</div>
First I'd like to thank Brad West who provided the base, thank you.
Attention: Tested only on standard github pages dependency, not tested
on v2, not tested outside of github pages dependency.
The code below is working perfectly on gitgub pages (Jekyll v3.9.2), so far I have not found bugs.
I could have spent more time and improved the code, but it's already working as it should, so I'm not going to waste any more time on it.
Result: before and after.
_config.yml
paginate: 10
paginate_path: /page/:num/
.pagination {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 3rem;
}
.pagination a,
.pagination span {
display: flex;
justify-content: center;
align-items: center;
width: 40px;
height: 40px;
border: 1px solid #efefef;
border-left: 0;
}
.pagination .active {
background: #f3f3f3;
pointer-events: none;
}
.pagination .active svg {
opacity: .3;
}
.pagination a:hover {
background: #f3f3f3;
cursor: pointer;
}
.pagination a:first-child,
.pagination span:first-child {
border-left: 1px solid #efefef;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
}
.pagination a:last-child,
.pagination span:last-child {
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
}
{% if paginator.total_pages > 1 %}
<div class="pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">
<svg width="8" height="16" viewBox="0 0 8 13">
<g fill="none" stroke="none" stroke-width="1" fill-rule="evenodd">
<g transform="translate(1.000000, 1.000000)" stroke="currentColor" stroke-width="2">
<polyline transform="translate(3.500000, 5.507797) rotate(90.000000) translate(-3.500000, -5.507797)" points="-1.5 3 3.5155939 8.0155939 8.5 3.0311879"></polyline>
</g>
</g>
</svg>
</a>
{% else %}
<span class="active">
<svg width="8" height="16" viewBox="0 0 8 13">
<g fill="none" stroke="none" stroke-width="1" fill-rule="evenodd">
<g transform="translate(1.000000, 1.000000)" stroke="currentColor" stroke-width="2">
<polyline transform="translate(3.500000, 5.507797) rotate(90.000000) translate(-3.500000, -5.507797)" points="-1.5 3 3.5155939 8.0155939 8.5 3.0311879"></polyline>
</g>
</g>
</svg>
</span>
{% endif %}
{% for page in (1..paginator.total_pages) %}
{% assign last_five = forloop.length | minus: 4 %}
{% assign last_page = forloop.length %}
{% if forloop.length > 5 %}
{% if paginator.page <= 5 %}
{% if forloop.index <= 5 %}
{% if forloop.first and page == paginator.page %}
<span class="active">{{ page }}</span>
{% elsif forloop.first %}
1
{% elsif page == paginator.page %}
<span class="active">{{ page }}</span>
{% else %}
{{ page }}
{% endif %}
{% else %}
{% if paginator.page == 5 %}
{{ page }}
{% endif %}
<span>...</span>
{{ last_page }}
{% break %}
{% endif %}
{% elsif paginator.page >= last_five %}
{% if forloop.index >= last_five %}
{% if forloop.index == last_five %}
1
<span>...</span>
{% if page == last_five %}
{{ page | minus: 1 }}
{% endif %}
{% if page == paginator.page %}
<span class="active">{{ page }}</span>
{% else %}
{{ page }}
{% endif %}
{% elsif forloop.last and page == paginator.page %}
<span class="active">{{ page }}</span>
{% elsif page == paginator.page %}
<span class="active">{{ page }}</span>
{% else %}
{{ page }}
{% endif %}
{% endif %}
{% else %}
{% if forloop.first %}
1
{% endif %}
{% if forloop.index == paginator.page | minus: 2 %}
<span>...</span>
{{ page | minus: 2 }}
{% endif %}
{% if forloop.index == paginator.page | minus: 1 %}
{{ page | minus: 1 }}
{% endif %}
{% if page == paginator.page %}
<span class="active">{{ page }}</span>
{% endif %}
{% if forloop.index == paginator.page | plus: 1 %}
{{ page | plus: 1 }}
{% endif %}
{% if forloop.index == paginator.page | plus: 2 %}
{{ page | plus: 2 }}
<span>...</span>
{% endif %}
{% if forloop.last %}
{{ forloop.index }}
{% endif %}
{% endif %}
{% else %}
{% if page == paginator.page %}
<span class="active">{{ page }}</span>
{% elsif page == 1 %}
{{ page }}
{% else %}
{{ page }}
{% endif %}
{% endif %}
{% endfor %}
{% if paginator.next_page %}
<a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">
<svg width="8" height="16" viewBox="0 0 8 13">
<g fill="none" stroke="none" stroke-width="1" fill-rule="evenodd">
<g transform="translate(-2.000000, 4.000000)" stroke="currentColor" stroke-width="2">
<polyline transform="translate(5.500000, 2.500000) rotate(90.000000) translate(-5.500000, -2.500000)" points="10.5 5 5.5 6.66133815e-16 0.5 5"></polyline>
</g>
</g>
</svg>
</a>
{% else %}
<span class="active">
<svg width="8" height="16" viewBox="0 0 8 13">
<g fill="none" stroke="none" stroke-width="1" fill-rule="evenodd">
<g transform="translate(-2.000000, 4.000000)" stroke="currentColor" stroke-width="2">
<polyline transform="translate(5.500000, 2.500000) rotate(90.000000) translate(-5.500000, -2.500000)" points="10.5 5 5.5 6.66133815e-16 0.5 5"></polyline>
</g>
</g>
</svg>
</span>
{% endif %}
</div>
{% endif %}
Actually, I know that this question has been a lot even just in stackoverflow, but still, the answers I found does not work for me - lots of them are asked long ago. But however, I'm trying to put an iframe inside a web page, and it's from the same origin. The problem is, every time I scroll, these annoying scrollbars came out. I've tried to make changes like adding overflow: hidden (which makes it worse - it disables scrolling!), scrolling="no" (same as overflow, disables scrolling), and more. Is there a simple way that I can remove the scrollbar on the iframe but still can scroll it? CSS are better, but if it can be done in JavaScript at someways, it's also OK. Thanks a lot!!
Update: My code:
the parent page: (things in {%%} and {{}} are jinja templates, I use them to render the template)
<!--
#Author: Sam Zhang
#Date: 2020-04-10 20:05:53
#Last Modified by: Sam Zhang
#Last Modified time: 2020-05-06 17:01:45
-->
{% extends 'base.html' %}
{% block title %}{{ keyword }}{% endblock %}
{% block top %}{% endblock %}
{% block content %}
<nav class="navbar navbar-dark bg-primary fixed-top">
<a class="navbar-brand" href="/">Guangdu <small class="text-light">Baidu</small></a>
<form method="post" class="container-fluid" style="max-width: 60%; margin-left: 0"
action="{{ url_for('baidu.index') }}">
<div class="input-group">
<input class="form-control" name="query" value="{{ keyword }}" id="search" autocomplete="off" type="search">
<button class="btn btn-success" type="submit">Guangdu</button>
</div>
</form>
<a onclick="changeTheme()" href="" class="text-white" title="Change theme"><i class="fa fa-adjust"></i></a>
</nav>
<br><br><br><br>
<div class="iframe-wrap">
<iframe id="iframe iframe-real" onload="$(this).fadeIn(500); show()" seamless="seamless" src="{{ url_for('baidu.search_s', q=keyword, page=cur) }}" class="iframe"></iframe>
</div>
<div class="d-flex justify-content-center" id="load-container">
<div class="spinner-grow text-primary" role="status" id="load">
<span class="sr-only" id="load-sr">Loading</span>
</div>
</div>
</div>
<script>
function hide() {
$("#iframe").hide();
$("#load-container").fadeIn(500);
$("#load").fadeIn(500);
$("#load-sr").fadeIn(500);
}
function show() {
$("#load-container").fadeOut(500);
$("#load").fadeOut(500);
$("#load-sr").fadeOut(500);
}
window.onload = hide();
</script>
{% endblock %}
And my web page in the iframe:
<!--
#Author: Sam Zhang
#Date: 2020-04-10 20:05:53
#Last Modified by: Sam Zhang
#Last Modified time: 2020-05-06 17:26:20
-->
{% extends 'base.html' %}
{% block title %}{{ keyword }}{% endblock %}
{% block top %}{% endblock %}
{% block body %}id="body" style="overflow:auto;height:100%" onload="document.getElementById('body').style.width=document.body.offsetWidth+20+'px'"{% endblock %}
{% block content %}
<style>
</style>
<script>
function change(pn) {
this.parent.location.href = "{{ url_for('baidu.search') }}?q={{ keyword }}&page=" + pn;
}
</script>
{% if results %}
{% for result in results %}
{% if result.title and result.link %}
<div class="container">
{% if result.domain %}
<p class="text-success">
{{ result.domain }}
{% if result.path %}
›
{% for loc in result.path %}
{% if loop.index != result.path | length %}
{{ loc }}
›
{% else %}
{{ loc }}
{% endif %}
{% endfor %}
{% endif %}
</p>
{% endif %}
<h5 id="{{ loop.index }}h5">{{ result.title }}</h5>
{% if result.time %}<p class="d-inline text-muted">{{ result.time }} · </p>{% endif %}<p class="d-inline text-secondary text-wrap" id="{{ loop.index }}">{% if result.des %}{{ result.des }}{% else %}No description{% endif %}</p>
<hr>
</div>
{% endif %}
{% endfor %}
{% else %}
<div class="container">
<p>Keyword {{ keyword }} has np search results</p>
</div>
{% endif %}
<div class="container">
<nav>
<ul class="pagination justify-content-center">
{% if cur != 0 and cur != 10 %}
{% set url = "javascript:change(pn='" + (cur - 1) | string + "')" %}
{% else %}
{% set url = '#' %}
{% endif %}
<li class="page-item{% if cur == 0 %} disabled{% endif %}">
<a class="page-link" href="{{ url }}" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
{% if pages | length <= 10 %}
{% for i in pages %}
<li class="page-item{% if i == cur %} active{% endif %}"><a class="page-link" href="javascript:change(pn='{{ i }}')">{{ i + 1 }}</a></li>
{% endfor %}
{% endif %}
{% if cur < pages | length %}
{% set url = "javascript:change(pn='" + (cur + 1) | string + "')" %}
{% else %}
{% set url = '#' %}
{% endif %}
<li class="page-item{% if cur == pages | length - 1 or cur == 9 %} disabled{% endif %}"{% if cur == 9 %} data-toggle="tooltip" data-placement="top"{% endif %}>
<a class="page-link" href="{{ url }}" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
</div>
{% endblock %}
Kind of a hacky solution, but this will hide the scrollbars by making the frame bigger than the container.
.outer {
width: 500px;
height: 150px;
overflow: hidden;
}
.outer iframe {
width: 520px;
height: 170px;
overflow: auto;
}
<div class="outer">
<iframe src="/"></iframe>
</div>