Django view template responsiveness - html

I am trying to work on the responsiveness of my django application on mobile view. So here is our it looks on a smaller screen size
So I want to remove all the white space that I have marked in blue, which is supposed to separate one post from the next. Here is the code snippet associated with that section
<section class="category-section">
<div class="container" data-aos="fade-up">
<div class="section-header d-flex justify-content-between align-items-center mb-5">
<h2>Politics</h2>
<div>See All Politics</div>
</div>
<div class="row">
{% for politic in politics%}
{% if forloop.counter < 11 %}
<div class="post-entry-1 col-lg-2 col-md-6 col-xs-12 mx-1">
<img src="{{politic.image.url}}" alt="" class="post_img img-fluid">
<div class="post-meta float-right">
<span class="date">{{politic.category}}</span>
<span class="mx-1">&bullet;</span>
<span>{{politic.created_at}}</span>
</div>
<h2 class="mb-2">{{politic.title}}</h2>
<span class="author mb-3 d-block">Ole Pundit</span>
<p class="mb-4 d-block">{{politic.body| safe | truncatewords:15}}</p>
</div>
{% endif %}
{% endfor %}
</div>
</div>
</section>
And here are some of the css style classes that are at play
.post-entry-1 {
margin-bottom: 30px;
}
.post-entry-1 img {
margin-bottom: 30px;
}
.post-entry-1 h2 {
margin-bottom: 20px;
font-size: 20px;
font-weight: 500;
line-height: 1.2;
font-weight: 500;
}
.post-entry-1 h2 a {
color: var(--color-black);
}
.post-entry-1.lg h2 {
font-size: 40px;
line-height: 1;
}
.post-meta {
font-size: 11px;
letter-spacing: 0.07rem;
text-transform: uppercase;
font-weight: 600;
font-family: var(--font-secondary);
color: rgba(var(--color-black-rgb), 0.4);
margin-bottom: 10px;
}
What could be the issue?

I can see that your CSS class name of .post-entry-1 is the main wrapper that wraps all contents of your post, and you gave margin-bottom value of 30px.
Maybe you may try delete it? Or, please take a look at .mx-1.

Related

why isn't the styling on the line break working?

I was doing a challenge on frontendmentor.io and I'm currently stuck on one thing: the styling on a line-break isn't being applied.
I've made a pen on codepen for ease : codepen link
Html code:
<main>
<div class="card">
<img class="card-img" src="./images/image-equilibrium.jpg" alt="blueish-red equilibrium cube">
<div class="card-content">
<h2 class="card-title">Equilibrium #3429</h2>
<p>Our Equilibrium collection promotes balance and calm.</p>
<div class="row card-icons">
<div class="eth row"><img class="eth-icon" alt="ethereum value to purchase item" src="./images/icon-ethereum.svg"><h3 class="icon-text">0.041eth</h3></div>
<div class="days-left row"><img class="clock-icon" alt="days-remaining icon" src="./images/icon-clock.svg"><h3 class="icon-text"> 3 days left</h3></div>
</div>
<hr class="line-break">
<div class="creator row">
<img class="creator-pfp" src="./images/image-avatar.png" alt="Creator profile picture">
<p>Creation of <strong>Jules Wyvern</strong></p>
</div>
</div>
</div>
</main>
css :
/* typography and styling */
h2 {
color: var(--title-color);
font-family: var(--title-font);
font-size: 1.75rem;
}
p {
color: var(--text-color);
font-family: var(--body-font);
font-weight: 300;
font-size: 1.125rem;
line-height: 1.5;
}
.eth .icon-text {
color: var(--text-color-eth);
font-family: var(--body-font);
text-transform: uppercase;
font-weight: 600;
}
.days-left .icon-text {
color: var(--text-color);
font-family: var(--body-font);
font-weight: 300;
}
hr.line-break {
border-top: 1px solid #aaaaea);
}
This is your code:
hr.line-break {
border-top: 1px solid #aaaaea;
}
Delete the )
You can add the styles for line break.
I Noticed that you have added ")" at the end. you have to remove it.
check this image
I don't think hr take in any style.
You can use an empty
<div class='line-break'></div>
instead
Like this
.line-break{
width:100vw;
hight:1px;
border-top: 1px solid #aaaaea;
}

How to position a heading in one corner and a button on the opposite corner

Expected: I am trying to get the same as in the following image.
Actual: But what I got is as in the following image
Here's my HTML:
<div class="heading-container d-flex flex-row justify-content-start">
<h1 class="main-heading"> Finding Nemo </h1>
<button class="button"> Watch Now </button>
</div>
And CSS:
.heading-container {
margin-top: 20px;
}
.main-heading {
color: #ffffff;
font-family: "Roboto";
font-size: 24px;
font-weight: bold;
}
.button {
background-color: #ffffff;
color: #ff8348;
border-width: 0px;
border-radius: 10px;
height: 32px;
width: 110px;
font-size: 13px;
}
I see you're using bootstrap, you can just add align-right to the class of your button:
<button class="button float-right"> Watch Now </button>
Can you please check the below code? Hope it will work for you. You just need to replace justify-content-start with justify-content-between bootstrap class in
heading-container. It will display the child items with space between the lines.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="heading-container d-flex flex-row justify-content-between">
<h1 class="main-heading"> Finding Nemo </h1>
<button class="button"> Watch Now </button>
</div>

How to select h4 heading

I'm trying to decrease my font size for a h4 header and change some other things but the h4 class, .awpcp-listing-title doesn't seem to function as a selector.
Tried several options, including important, like the code I have here:
.awpcp-listing-title {
font-size: 10px;
margin-right: 50px;
padding: 15px;
}
<div class="awpcp-listing-excerpt-inner" style="w">
<h4 class="awpcp-listing-title">Scarf</h4>
<div class="awpcp-listing-excerpt-content">Grey scarf</div>
</div>
<div class="awpcp-listing-excerpt-extra">
05/10/2019<br/>
.awpcp-listing-title {font-size: 10px !important;}
the !important is very "important" to make sure your CSS will be applied.
.awpcp-listing-title a
{
font-size: 10px!important;
margin-right: 50px;
padding:15px;
}
<div class="awpcp-listing-excerpt-inner" style="w">
<h4 class="awpcp-listing-title">Scarf</h4>
<div class="awpcp-listing-excerpt-content">Grey scarf</div>
</div>
<div class="awpcp-listing-excerpt-extra">
05/10/2019<br/>
Check and try this code
You really should not use !important as all the other answers suggest - you simply need to find the right selector and it is is NOT the h4 - its the a within it.
Simply put - browers render h4's with default styling, so first - clear that using the h4 element as the selector - then target its child - the a element.
I have styled it red to show that it is targetted.
h4 {
margin: 0;
padding: 0;
}
.awpcp-listing-title a {
font-size: 10px;
margin-right: 50px;
padding 15px;
color: red;
}
<div class="awpcp-listing-excerpt-inner" style="w">
<h4 class="awpcp-listing-title">
Scarf
</h4>
<div class="awpcp-listing-excerpt-content">Grey scarf</div>
</div>
<div class="awpcp-listing-excerpt-extra">
05/10/2019<br/>
h4.awpcp-listing-title{
font-size:20px !important;
}
<div class="awpcp-listing-excerpt-inner">
<h4 class="awpcp-listing-title">Scarf</h4>
<div class="awpcp-listing-excerpt-content">Grey scarf</div>
</div>
<div class="awpcp-listing-excerpt-extra">
05/10/2019<br/>
</div>
remove style="w" incorrect stansted code
The reason behind your code is not working is that you are using anchor tag and your css has no code to change that font-size.
.awpcp-listing-title a{
font-size: 10px;
margin-right: 50px;
padding : 15px;
}
<div class="awpcp-listing-excerpt-inner" style="w">
<h4 class="awpcp-listing-title">Scarf</h4>
<div class="awpcp-listing-excerpt-content">Grey scarf</div>
</div>
<div class="awpcp-listing-excerpt-extra">
05/10/2019<br/>
I have modified the CSS code slightly. No need to include the URL selector.
h4.awpcp-listing-title {
font-size: 10px!important;
margin-right: 50px;
padding: 15px;
}

Bootstrap 3 code not working as expected

So I uploaded a question that's the same as this one, however, that got very overcrowded so I am putting up the question again in hopes of explaining my problem a bit better.
I am currently making my own website using HTML, CSS, and JavaScript with bootstrap alongside. While trying to make the site mobile friendly, I have noticed an error with how 3 of the buttons are being displayed on the screen. Basically, what I want to happen is for the three buttons to be stacked on top of each other with a gap in between each one when the web page is viewed on mobile. However, the buttons aren't displaying correctly. See the first image.
One thing that I will say, though, is that I am using the feature (not sure if it's only in Google Chrome) that when you click inspect element, you can select an option that allows you to view what the web page will look like on a mobile screen. What I'm getting at, is that I don't know if it's the code that's wrong or if Google Chrome's feature doesn't work that well.
If you do have any suggestions for applications I could use to view the HTML file on a mobile device, please let me know.
PLEASE NOTE. I HAVE ONLY GIVEN THE CODE FOR ONE OF THE BUTTONS AS THE OTHER TWO ARE BASICALLY THE SAME
#media (max-width: 767px){
.btn-block-xs {
display: block;
width: 100%;
margin-bottom: 10px;
}
}
#cheapestOption {
font-family: 'Pavanam', sans-serif;
background-color: rgba(255,255,255,0.3);
border: none;
}
#cheapestOption a {
text-decoration: none;
color: white;
}
#cheapestOption p {
font-family: 'Pavanam', sans-serif;
font-size: 50px;
}
#cheapestOption ul{
text-align: left;
font-size: 17px;
}
#cheapestOption:hover {
background-color: rgba(255, 255, 255, 0.6);
text-decoration: none;
}
<div class="container-fluid" id="grad"> <!-- Pricing Buttons -->
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-4">
<button type="button" id="cheapestOption" class="btn btn-block-xs" aria-label="center Align">
<a href="pricing.html" target="_blank">
<h4>Text</h4>
<p><strong>£££</strong><span>/ £5 a month</span></p>
<ul>
<li> Text </li>
<li> Text </li>
<li> Text </li>
<li> Text </li>
</ul>
</a>
</button>
</div>
(First picture shows what it looks like on mobile) (this is what needs fixing)
(Second picture shows what it looks like on desktop) (this is fine)
You html and css are not really following the bootstrap documentation. I suggest you read more on how bootstrap works. You can simplify a lot of what you are doing and probably make things look a lot better too.
I would suggest create a button which is a link and move the text out of it. To answer your question exactly please see this jsfiddle.
I moved your html to be in the correct col class Let me know if you have anymore questions,
html
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-4"><button type="button" id="cheapestOption" class="btn btn-block-xs" aria-label="center Align">
<a href="pricing.html" target="_blank">
<h4>Text</h4>
<p><strong>£££</strong><span>/ £££ a month</span></p>
<ul>
<li> Text </li>
<li> Text </li>
<li> Text </li>
<li> Text </li>
</ul>
</a>
</button></div>
<div class="col-md-4 col-sm-4 col-xs-4"> <button type="button" id="averageOption" class="btn btn-block-xs" aria-label="center Align">
<a href="pricing.html" target="_blank">
<h4>Text</h4>
<p><strong>£££</strong><span>/ £££ a month</span></p>
<ul>
<li> Text </li>
<li> Text </li>
<li> Text </li>
<li> Text </li>
</ul>
</a>
</button></div>
<div class="col-md-4 col-sm-4 col-xs-4"> <button type="button" id="expensiveOption" class="btn btn-block-xs" aria-label="center Align" disabled>
<h4>Text</h4>
<p><strong>£££</strong><span>/ £££ a month</span></p>
<p id="tempBottom"><strong>Coming Soon</strong></p>
</button></div>
</div>
</div>
CSS
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
#cheapestOption {
font-family: 'Pavanam', sans-serif;
background-color: red;
border: none;
}
#cheapestOption a {
text-decoration: none;
color: white;
}
#cheapestOption p {
font-family: 'Pavanam', sans-serif;
font-size: 1em;
}
#cheapestOption ul {
text-align: left;
font-size: 17px;
}
#cheapestOption:hover {
background-color: rgba(255, 255, 255, 0.6);
text-decoration: none;
}
#averageOption {
font-family: 'Pavanam', sans-serif;
width: 100%;
background-color: red;
border: none;
color: white;
}
#averageOption a {
text-decoration: none;
color: white;
}
#averageOption p {
font-family: 'Pavanam', sans-serif;
font-size: 1em;
}
#averageOption ul {
text-align: left;
font-size: 17px;
}
#averageOption:hover {
background-color: rgba(255, 255, 255, 0.6);
}
#expensiveOption {
font-family: 'Pavanam', sans-serif;
width: 100%;
background-color: red;
border: none;
color: white;
}
#expensiveOption a {
text-decoration: none;
color: white;
}
#expensiveOption p {
font-family: 'Pavanam', sans-serif;
font-size: 1em;
}
#expensiveOption ul {
text-align: left;
font-size: 1em;
}
To simplify this for you here are a few things to remember,
Bootstrap is built for mobile first.
Each row consist of 12 pieces, so when you tell it col-md-4 you are saying that when the browser is the width of col-md you want that space to take up 1/3 of the width of the row.
You can target each browser size by default css built into bootstrap using col-xs col-sm -col-md etc... To see the default size of each col-size check the documentation or inspect element and check the class in the DOM.
Bootstrap Grid System
If you want the col-size to stack at certain screen widths this is what you can do.
If when the screen is sm you want them to stack you could do,
<div class="row">
<div class="col-sm-12">
<p>My text here will be on this row alone.</p>
</div>
<div class="col-sm-12">
<p>My text here will be on this row alone.</p>
</div>
<div class="col-sm-12">
<p>My text here will be on this row alone.</p>
</div>
</div> <!-- end of row -->
This will stack on sm size because when the screen is the width of the sm size it will take up 12 which is the whole space. So that media query will fire off and the col will now take up the whole row.
Remeber you can stack each class as well. So if you want to make sure each col stack starting with md you could do this,
<div class="col-xs-12 col-sm-12 col-md-12 ">
Now when the browser is at each of those class target widths whatever html is in that div will take up the whole row.

text not aligns to centers on #media screen and (min-width:992px) and (max-width:1199px)

the heading and sub heading of a slider is not center aligned its working fine all on other screen sizes but in this screen size the heading and subheading floats to the left
#media screen and (min-width:992px) and (max-width:1199px) {
.position{
position: absolute;
padding-top: 240px;
}
.swiper-slide{
text-transform: uppercase;
letter-spacing: 3px;
font-size: 60px;
line-height: 79px!important;
color: #fff;
}
.subtitle{
font-family: 'Rouge Script', cursive;
font-size: 40px;
line-height: 39px!important;
font-weight: 400;
color: #fff;
font-style: italic;
}
}
i'm using text-center bootstrap class for aligning the text
My HTML
<div class="item text-center">
<div class="position col-lg-12">
<h1 class="swiper-slide">
<strong>
welcome to the shop
</strong>
</h1>
<p class="subtitle">
<span>
Take your time looking around & don't be shy
</span>
</p>
<p class="top-space">
<button type="button" class="btn btn-default btn-lg button hvr-float-shadow" id="focus">
START BROWSING
</button>
</p>
</div>
<img src="img/front_girl1.jpg">
</div>
Use text-align:center; will align text in center .
check below code
.swiper-slide{
text-align: center;
}
.subtitle{
text-align: center;
}
this is cause the issue :
.position{
position: absolute;
padding-top: 240px;
}
remove absolute position and it will work properly
LIVE DEMO
It should work regardless of the positioning context. You should check specificity and display type(if element set to display:inline than text align will not apply directly to that element). Hard to say without live demo. Can you provide more code or a complete fiddle ?