Issue with implementing a grid - html

Within an shopify homepage image grid I'd like to overlay a number of things on top of each image: e.g. on top of the blue shirt 2 text divs (TEXTLINE 1 and TEXTLINE 2)and 1 image. When I add the text lines everything looks as it should:
But, when I include the image (white flower) the parent image is enlarged. TEXTLINE 2 hast the markup cta-text and the image cta-image
This is my CSS:
.tile-group {
position: relative;
overflow: hidden;
.tile { display: none; }
.tile.loaded {
position: absolute;
display: block;
}
img {
width: 100%;
}
a {
display: block;
#include vendor-prefix(transition, opacity 300ms);
&:hover {
opacity: $image-hover-opacity;
}
}
.overlay {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
text-align: center;
&:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-left: -5px;
}
.inner {
#extend h4;
color: $home-tile-text-col;
margin: 0;
padding: 0;
display: inline-block;
vertical-align: middle;
width: auto;
padding: 20px 25px;
#if $home-tile-text-bg-col != transparent and $home-tile-text-bg-col != rgba(0,0,0,0) {
background: rgba($home-tile-text-bg-col, $home-tile-text-bg-transparency);
}
.cta-text{
width: 30%;
position: absolute;
font-size:24px;
left:35%;
bottom: 5%;
text-transform: uppercase;
}
.cta-image{
width: 30%;
position: absolute;
left: 35%;
bottom: 10%;
}
}
}
}
<div class="tile">
{% if settings[url_idx] != empty %}<a href="{{ settings[url_idx] | escape }}">{% endif %}
<img src="{% comment %}ly_asset_replace_for_[ filename | asset_url ]_begin{% endcomment %}{% assign ly_asset = filename %}{% include 'ly-asset' with ly_asset %}{{ ly_translation }}{% comment %}ly_asset_replace_end{% endcomment %}" alt="{{ settings[alt_idx] | escape }}" />
{% if settings[overlay_idx] != blank %}
<div class="overlay">
<div class="inner">
{{ settings[overlay_idx] }}
<div class="cta-image">
{{ "lotos.png" | asset_url | img_tag:"CTA Image" }}
</div>
<div class="cta-text">
{{ settings[cta_text] }}
</div>
</div>
</div>
{% endif %}
{% if settings[url_idx] != empty %}</a>{% endif %}
</div>
{% endcapture %}
{% endif %}
{% endfor %}
<section class="border-top section tile-section">
<div class="container">
<div class="tile-group">
{{ img_tiles_html }}
</div>
</div>
</section>
Outputted HTML is here
How can I get the grid behave as in screenshot 1?

Related

Display Messages notifications inside a div box

When the user enter a not valid credentials it print this notificaitons message:
Sorry, your password was incorrect.<br/> Please double-check your password
But this doesn't look good when it is printed:
I want it to be printed between the Login button and the Forgot password.
Like that:
So theoretically the white box should expend to the bootom to leave so place for the notifications message
html file
<div class="testlol2" >
<div class="login-box" align="center">
<img class="logo" src="{% static 'images/testlogo.png' %}" alt="">
<div class="testlol" align="center">
<form action="" method="post">
{% csrf_token %}
{{ form|crispy }}
<div class="my-button">
<input class="login-button" type="submit" value="Log in">
</div>
</form>
{% if messages %}
<ul class="messages">
{% for message in messages %}
<p{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</p>
{% endfor %}
</ul>
{% endif %}
<a class="forgot" href="">Forgot password?</a>
</div>
</div>
</div>
css file
body{
background-color: #fafafa !important;
}
.messages {
position: relative;
top: 10px;
right: 8px;
color: red;
}
.logo {
position: relative;
top: 28px;
left: 134px;
width: 200px;
}
.testlol {
position: relative;
top: 115px;
right: 90px;
}
.testlol2 {
display:flex;
justify-content: center;
}
.login-box {
display:flex;
justify-content: center;
align-items: start;
align-self: center;
position: relative;
top: 100px;
background: #fff;
border: 1px solid #e6e6e6;
border-radius: 1px;
margin:0 0 10px;
padding: 10px 0;
height: 280px;
width: 325px;
}
.forgot {
position: absolute;
top: 128px;
right: 95px;
font-size: 12px;
margin-top: 12px;
text-align: center;
color: #000000;
line-height: 14px!important;
text-decoration: none;
}
Your code (css) is quite a mess. I tried making some minimal changes to it would partly look ok. Main fix was to make the .messages have margin of 115px from top rather than be positioned 115px from top, so that login-box would expand in height.
body {
background-color: #fafafa !important;
}
.messages {
position: relative;
top: 10px;
right: 8px;
color: red;
}
.logo {
position: relative;
top: 28px;
left: 134px;
width: 200px;
}
.testlol {
position:relative;
right: 90px;
margin-top: 115px;
}
.testlol2 {
display: flex;
justify-content: center;
}
.login-box {
display: flex;
justify-content: center;
align-items: start;
align-self: center;
position: relative;
top: 100px;
background: #fff;
border: 1px solid #e6e6e6;
border-radius: 1px;
margin: 0 0 10px;
padding: 10px 0;
/* height: 280px; */
width: 325px;
}
.forgot {
/* position: absolute; */
top: 128px;
right: 95px;
font-size: 12px;
margin-top: 12px;
text-align: center;
color: #000000;
line-height: 14px!important;
text-decoration: none;
}
<div class="testlol2">
<div class="login-box" align="center">
<img class="logo" src="{% static 'images/testlogo.png' %}" alt="">
<div class="testlol" align="center">
<form action="" method="post">
{% csrf_token %} {{ form|crispy }}
<div class="my-button">
<input class="login-button" type="submit" value="Log in">
</div>
</form>
{% if messages %}
<ul class="messages">
{% for message in messages %}
<p{% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}</p>
{% endfor %}
</ul>
{% endif %}
<a class="forgot" href="">Forgot password?</a>
</div>
</div>
</div>

How to decrease the slider speed in Django?

Please help to decrease speed, it's too fast. Searched a lot in google and everywhere there is Bootstrap solution. I even tried Bootstrap, that was too slow and different icons which didn't look good. Also Bootstrap version center it's PREV and NEXT icons for each image, which is also not looking good as I have different image height.
Is there any way to change speed in my current carousel? Please help.
my CSS looks like
/* PRODUCT DETAIL SLIDER START */
.product_detail-slider{
position: relative;
}
.product_detail-slider .owl-stage-outer{
overflow-x: hidden;
}
.product_detail-slider .owl-stage{
display: flex;
}
.product_detail-slider .owl-nav .owl-prev{
position: absolute;
top: calc(50% - 80px);;
left: 0;
border: none;
background-color: transparent;
}
.product_detail-slider .owl-nav .owl-prev span{
color: rgba(0, 0, 0, 0.30);
font-size: 80px;
transition: all 2s;
}
.product_detail-slider .owl-nav .owl-prev span:hover{
color: #000000;
}
.product_detail-slider .owl-nav .owl-next{
position: absolute;
top: calc(50% - 80px);
right: 0;
border: none;
background-color: transparent;
}
.product_detail-slider .owl-nav .owl-next span{
color: rgba(0, 0, 0, 0.30);
font-size: 80px;
transition: all 2s;
}
.product_detail-slider .owl-nav .owl-next span:hover{
color: #000000;
}
.owl-dots{
display: none;
}
/* PRODUCT DETAIL SLIDER END */
my HTML
<div class="product_detail-slider">
<div class="product_detail-slider_block">
<img src="{{ product.image_url }}" alt="" style="width:100%; padding-bottom: 20px;">
</div>
{% if product.image_2_url %}
<div class="product_detail-slider_block">
<img src="{{ product.image_2_url }}" alt="" style="width:100%; padding-bottom: 20px;">
</div>
{% endif %}
{% if product.image_3_url %}
<div class="product_detail-slider_block">
<img src="{{ product.image_3_url }}" alt="" style="width:100%; padding-bottom:20px;">
</div>
{% endif %}
{% if product.image_4_url %}
<div class="product_detail-slider_block">
<img src="{{ product.image_4_url }}" alt="" style="width:100%; padding-bottom:20px;">
</div>
{% endif %}
{% if product.image_5_url %}
<div class="product_detail-slider_block">
<img src="{{ product.image_5_url }}" alt="" style="width:100%; padding-bottom:20px;">
</div>
{% endif %}
{% if product.image_6_url %}
<div class="product_detail-slider_block">
<img src="{{ product.image_6_url }}" alt="" style="width:100%; padding-bottom:20px;">
</div>
{% endif %}
</div>

<hr> below each three <div>s

I'm trying to put a <hr> below each three <div>s (one <hr> per three <div>s), however I'm getting unexpected results. I came to the conclusion that I have to put a <hr> below each third <div>, but when I do that, it is not positioned correctly (see the demo).
I am using this Django template:
{% extends 'pages/base.html' %}
{% load static %}
{% block cssfiles %}
<link rel="stylesheet" href="{% static 'products/css/list.css' %}" />
{% endblock %}
{% block jsfiles %}
<script type="text/javascript" src="{% static 'products/js/ellipsis.js' %}" defer></script>
{% endblock %}
{% block content %}
{% for product in products %}
<div class='product'>
<div class='product-title'>{{ product.title }} ({{ product.year }})</div>
<hr class='product-separator'>
{% if product.image %}
<div class='product-image'>
<img src='{{ product.image.url }}' width='100' height='100'>
</div>
{% endif %}
<p class='product-price'>${{ product.price }}</p>
</div>
{% if forloop.counter|add:1|divisibleby:3 %}
<hr>
{% endif %}
{% endfor %}
{% endblock %}
Here is the jsfiddle link.
Consider using CSS Grid and Flexbox for finer grained control. See the four CSS rules I added at the top of your code:
.grid{
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
.grid > hr{
grid-column: 1/4;
width: 100%;
}
.product {
display: flex;
flex-flow: column;
}
.product > .product-price{
margin-top: auto;
padding-top: 15px;
}
ul#menu {
position: relative;
}
ul {
list-style-type: none;
margin: 0;
padding :0;
}
li {
display: inline-block;
margin-right: 1px;
}
li a {
display:block;
min-width:103px;
height: 30px;
text-align: center;
line-height: 30px;
font-family: "Share Tech Mono";
color: #fff;
background: #2f3036;
text-decoration: none;
}
/*.product {
float: left;
width: 215px;
max-width: 215px;
height: 215px;
max-height: 215px;
}*/
.product-title {
color: #62646a;
margin-top: 10px;
margin-left: 10px;
margin-right: 10px;
font-weight: bold;
font-size: 13px;
line-height: 13px;
/*height: 26px;
overflow: hidden;*/
}
.product-description {
margin-left: 10px;
margin-right: 10px;
font-size: 12px;
text-align: justify;
text-justify: inter-word;
}
.product-separator {
height: 1px;
border-top: 1px;
border-left: 1px;
border-right: 1px;
margin-left: 10px;
margin-right: 10px;
color: #d9d7d7;
}
.product-image img {
display: block;
margin: auto;
margin-top: 20px;
}
.product-price {
color: #62646a;
margin-top: 15px;
margin-left: 10px;
font-size: 18px;
}
.product:hover {
background: #f5f3f2;
}
body {
margin: auto;
max-width: 800px;
}
<nav>
<ul id='menu'>
<li>Home</li>
<li>Shop</li>
<li>Contact</li>
<li>About</li>
</ul>
</nav>
<div class="grid">
<div class='product'>
<div class='product-title'>Franz Joseph (1917)</div>
<hr class='product-separator'>
<p class='product-price'>$100.00</p>
</div>
<div class='product'>
<div class='product-title'>Krugerrand South Africa (1917)</div>
<hr class='product-separator'>
<p class='product-price'>$200.00</p>
</div>
<div class='product'>
<div class='product-title'>Morgan Silver Dollar (1965)</div>
<hr class='product-separator'>
<div class='product-image'>
<img src='http://placekitten.com/200/200' width='100' height='100'>
</div>
<p class='product-price'>$50.00</p>
</div>
<hr>
<div class='product'>
<div class='product-title'>Peace Silver Dollar (1934)</div>
<hr class='product-separator'>
<div class='product-image'>
<img src='http://placekitten.com/200/200' width='100' height='100'>
</div>
<p class='product-price'>$75.00</p>
</div>
<div class='product'>
<div class='product-title'>Kralj Petar Drugi (1978)</div>
<hr class='product-separator'>
<div class='product-image'>
<img src='http://placekitten.com/200/200' width='100' height='100'>
</div>
<p class='product-price'>$1.00</p>
</div>
<div class='product'>
<div class='product-title'>Kralj Stefan Prvi Prvovencani Kotromanic (1389)</div>
<hr class='product-separator'>
<p class='product-price'>$1000.00</p>
</div>
</div>
it's the float that's breaking everything since you're telling the browser to display the products next to eachother.
try this:
</div>
{% if forloop.counter|add:1|divisibleby:3 %}
<hr style="clear:both;">

CSS align:vertical; not working properly in Firefox

I am trying to vertically center the contents of .onesizechart, which I have working in both Chrome and Safari, but does not work in either Firefox or IE. In Chrome and Safari the contents displays like so on hover but in Firefox and IE the contents display like this when I hover . The live site is here Not exactly sure what is causing this.
HTML/Liquid
<div class="medium-3 small-6 columns homepage-products left" onclick="location.href='{{ product.url }}'">
<a href="{{ product.url | within: collection }}">
<img src="{{ product.featured_image | product_img_url: 'grande' }}" alt="{{ product.title | escape }}" />
</a>
{% assign contains_os = false %}
{% for variant in product.variants %}
{% if variant.title contains 'OS' %}
{% assign contains_os = true %}
{% endif %}
{% endfor %}
{% if contains_os %}
<div class="onesizechart">
{% for variant in product.variants %}
{% if variant.inventory_quantity == 0 %}
<img src="{{ 'onesize-triangle-outofstock.png' | asset_url }}"/>
{% else %}
<img src="{{ 'onesize-triangle.png' | asset_url }}"/>
{% endif %}
{% endfor %}
</div>
{% else %}
<div class="homepage-sizechart">
<div class="sizes">
{{ 'size-triangle.png' | asset_url | img_tag }}
{% for variant in product.variants %}
<span class="{{ variant.title }}-product {% if variant.inventory_quantity == 0 %}outofstock{% endif %} {% if variant.title contains 'OS'%}hide{% endif %}">{{ variant.title }}</span>
{% endfor %}
</div>
</div>
{% endif %}
</div>
CSS
.homepage-products {
cursor: pointer;
margin-top: 20px;
}
.onesizechart {
opacity: 0;
position: absolute;
display: table;
width: 90%;
z-index: 999;
top: 5%;
bottom: 0;
right: 0;
margin: auto;
text-align: center;
}
.homepage-sizechart {
bottom: 0;
display: table-cell;
left: 0;
margin: auto;
opacity: 0;
position: absolute;
right: 0;
text-align: center;
top: 5%;
vertical-align: middle;
width: 90%;
z-index: 999;
}
.sizes {
position: relative;
}
Try this
change it display: inline-block; top: 30%;
.onesizechart {
opacity: 0;
position: absolute;
display: inline-block;
width: 90%;
z-index: 999;
top: 30%;
bottom: 0;
right: 0;
margin: auto;
text-align: center;
}

Problem centering footer in my Django template [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I'm having problems trying to center my footer in my Django template. The footer div class is Pagination.
Base HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Flickr Photobrowser</title>
<style>
html, body {
height: 100%;
}
* {
margin: 0;
padding: 0;
}
#wrap {
min-height:100%;
}
#header {
background: #111;
color: white;
}
#header, #content {
padding: 10px 150px 10px 150px;
}
#content {
overflow:auto;
padding-bottom: 150px; /* must be same height as the footer */
}
pagination {
position: relative;
margin-top: -150px; /* negative value of footer height */
height: 150px;
text-align: center;
}
h1 {
font-family: Georgia;
font-weight: 100;
font-style: italic;
font-size: 30px;
padding-top: 50px;
}
h2 {
font-size:20px;
margin-top: 5px;
color: #ff0080;
margin-bottom: 5px;
}
#image {
float:left;
padding: 2px;
}
.thumbnail {
position: relative;
z-index: 0;
}
.thumbnail:hover {
background-color: transparent;
z-index: 50;
}
.thumbnail span { /*CSS for enlarged image*/
position: absolute;
background-color: lightyellow;
padding: 5px;
left: -1000px;
border: 1px solid #000000;
visibility: hidden;
color: black;
text-decoration: none;
}
.thumbnail span img { /*CSS for enlarged image*/
border-width: 0;
padding: 2px;
}
.thumbnail:hover span { /*CSS for enlarged image on hover*/
visibility: visible;
margin-left: auto;
margin-right: auto;
top: 0;
left: 10px; /*position where enlarged image should offset horizontally */
}
</style>
</head>
<body>
<div id="wrap">
<div id="header"><h1>Flickr Photobrowser</h1></div>
<div id="content">
{% block content %}
<h2>Welcome!</h2>
<p>This sample application is here to show you how you can authenticate against Twitter using their
new oAuth API.<br>Press the big button below to authenticate.</p>
<p><a class="auth" href="auth/">Authenticate ยป</a></p>
{% endblock %}
</div>
</div>
{% block footer %}
{% endblock %}
</body>
</html>
Actual Page HTML:
{% extends "base.html" %}
{% block content %}
<form method="get" action="../photouser/">
Flickr username: <input type="text" name="username">
<input type="submit" value="submit">
</form>
<p>Search by tags?</p>
<p><h2>Displaying photos for {{ username }}</h2></p>
<ul>
{% for photosmall, photobig, actualimage in photopages.object_list %}
<div id="image"><a class="thumbnail" href="{{ actualimage }}">
<img src="{{ photosmall }}"/><span><img src="{{ photobig }}"/></span>
</a></div>
{% endfor %}
</ul>
{% endblock %}
{% block footer %}
<div class="pagination">
<span class="step-links">
{% if photopages.has_previous %}
Previous
{% endif %}
<span class="current">
Page {{ photopages.number }} of {{ photopages.paginator.num_pages }}
</span>
{% if photopages.has_next %}
Next
{% endif %}
</span>
</div>
{% endblock %}
It looks like a simple typo is your only problem.
You have this CSS:
pagination {
position: relative;
margin-top: -150px; /* negative value of footer height */
height: 150px;
text-align: center;
}
That's looking for an element like <pagination>, which you don't have (or want).
Instead, your element is:
<div class="pagination">
So, change your CSS selector to:
.pagination