change color of button after click - html

I have a question with four answers and I want the button to flash green when the correct answer is selected and red when the wrong answer is selected. How can I do that?
i want to solve this problem with django and not with javascript.
html
{% for q in questions %}
{% if q.kategorie == category and q.flaag == True %}
{% if questions.has_next %}
<br/>
<div class="flex-container">
<div class="container1">
<div class="position_startButton"><button type="submit" name="next" value="{{q.question}}" class="nächstefrage_btn">Nächste Frage!</button></div>
<div class="game_options_top">
<div class="option">
<p><button class="option_btn" name="next" value="{{erste_frage}}" formaction="{% url 'quiz' %}?page={{ questions.next_page_number }} " type="submit">A: <span id="option_span">{{erste_frage}}</span></button></p>
</div>
<div class="option">
<p><button class="option_btn" name="next" [ngClass] = value="{{zweite_frage}}" formaction="{% url 'quiz' %}?page={{ questions.next_page_number }} " type="submit">B: <span id="option_span">{{zweite_frage}}</span></button></p>
</div>
</div>
<div class="game_question">
<h1 class="display_question">{{q.question}}</h1>
</div>
<div class="game_options_bottom">
<div class="option">
<p><button class="option_btn" name="next" value="{{dritte_frage}}" formaction="{% url 'quiz' %}?page={{ questions.next_page_number }} " type="submit">C: <span id="option_span">{{dritte_frage}}</span></button></p>
</div>
<div class="option">
<p><button class="option_btn" name="next" value="{{vierte_frage}}" formaction="{% url 'quiz' %}?page={{ questions.next_page_number }} " type="submit">D: <span id="option_span">{{vierte_frage}}</span></button></p>
</div>
</div>
</div>
<div class="menü">
<button class="menü_button" formaction="{% url 'Example_dashboard' %}" ><i class="fa fa-bars" aria-hidden="true"></i><b> Menü</b></button>
<div class="items">
<i class="fa-solid fa-house"></i> Startseite
<i class="fa-solid fa-pen"></i> Fragenkatalog
<i class="fa-solid fa-trophy"></i> Statistik
<i class="fa-solid fa-gear"></i> Einstellungen
<i class=></i> Log-Out
</div>
</div>
</div>
<div class="buttons">
<div class="position_begründung_button">
<button class="begründung_button">Begründung</button>
</div>
<div class="position_fragemelden_button">
<button class="fragemelden_button">Frage melden</button>
</div>
<div class="position_quizbeenden_button">
<button class="quizbeenden_button" formaction="{% url 'Example_dashboard' %}">Quiz beenden</button>
</div>
</div>
<div id="footer">
<a class="information" href="https://www.google.at/?hl=de.">Impressum |</a>
<a class="information" href="https://www.google.at/?hl=de.">Datenschutz |</a>
<a class="information" href="https://www.google.at/?hl=de.">Support</a>
</div>
{% elif questions.has_previous %}

As far as I know, any Django solution needs a redirect or page reload. I assume you're not looking for something like this. Otherwise you can handle it with sending a new context to your template.
Anyway, if you don't want to use JS you can do that with this CSS trick. I'm not aware of the browsers' support status.
HTML:
<div id="nothing"></div>
<div id="one"></div>
<div class="styleSelector">
<a href='#nothing'>Nothing</a>
<a href='#one'>style 1</a>
</div>
<main class="scene">
<div class="carre">
</div>
</main>
CSS:
.scene .carre{
width:200px;
height:200px;
background-color:red;
-webkit-transition: all 1s;
-moz-transition: all 1s;
transition: all 1s;
}
#one:target ~ .scene .carre {
width:700px;
background-color:blue;
}

Related

elements in a foreach loop getting different css/bootstrap styles in laravel

am getting this weird bug whereby css styles are only applying to the first 2 items in my foreach loop.here is my code.
//html code
<div class="row">
#if ($housescategory->isEmpty())
<div class="col-lg-4">
No houses Found At the Moment
</div>
#else
#foreach ($housescategory as $rentalhse)
<div class="col-lg-4">
<section class="card hsecard">
<figure>
<div class="img-overlay hot-home">
#if($rentalhse->vacancy_status==1)
<span class="badge badge-info p-2 rounded-0 statusbadge">Vacants Available</span>
#elseif($rentalhse->vacancy_status==2)
<span class="badge badge-success p-2 rounded-0 statusbadge">Fully Booked</span>
#endif
<img src="{{ asset ('imagesforthewebsite/rentalhouses/rentalimages/medium/'.$rentalhse->rental_image) }}" alt="{{ $rentalhse->rental_name }}">
</div>
{{ $rentalhse->id }}<figcaption>{{ $rentalhse->rental_name }}
</figcaption>
<div class="pricelocation" style="display: flex;
justify-content: space-between;">
<section class="location">
<a class="disabled font-italic h6"><i class="fa fa-map-marker"></i>{{ $rentalhse->houselocation->location_title }}</a>
</section>
<section class="pricelink">
<span class="btn btn-dark">sh.{{ $rentalhse->monthly_rent }}</span>
</section>
</div>
</figure>
<div class="card-content">
<p>{!! Str::limit($rentalhse->rental_details, 80)!!}</p>
<section class="icons-home">
<div class="name-icon">
#if ($rentalhse->cctv_cameras == 'yes')
<span>CCtv Security Cameras</span>
<div class="icon">
<i class="fa fa-camera-retro"></i>
<span>Available</span>
</div>
#endif
</div>
<div class="name-icon">
#if ($rentalhse->parking == 'yes')
<span>Parking</span>
<div class="icon">
<i class='fas fa-parking'></i>
<span>Available</span>
</div>
#endif
</div>
<div class="name-icon">
#if ($rentalhse->generator == 'yes')
<span>Backup Generator</span>
<div class="icon">
<i class="fa fa-bolt"></i>
<span>Available</span>
</div>
#endif
</div>
</section>
</div>
<div class="viewprice" style="display: flex;
justify-content: space-between; margin:0px !important;">
<section class="viewlink">
Contact Admin
</section>
<section class="viewlink">
<a class="btn-sm btn-warning" href="{{ url('rentalhse/'.$rentalhse->rental_slug.'/'.$rentalhse->id) }}" role="button" >
View Details
</a>
</section>
</div>
</section>
</div>
#endforeach
#endif
here its how it looks like in the page .here the paragraph starts getting itaicised which is a different style from the first one.. here is the other part here the column gets smaller different from the set one in the row.its been giving me headache i havent understood why its coming up.

CSS - Scroll bar not working

I created chatbox UI for my Application. I want to add scroll bar for the chatbox. I added the overflow-y:auto; in chat-content div class. But it doesn't work.If I add the style in chat div class it will work both messages and input box also. But I need scroll only messages. I don't know where to add the overflow-y:auto;
Any one please find the solution for me.
Here I attached the html code for chatbox.
I followed this tutorial:
https://codepen.io/CodeFrogShow/pen/PKYvMo
html:
<div class="container_chatbot">
<div class="app">
<div class="head clearfix">
<span class="messages-notification">
<i class="fa fa-comments-o"></i>
<span class="count"></span>
</span>
<span class="title">Messenger</span>
<span class="create-new">
<a (click) = "onVisible()" class="close">
<i class="material-icons">expand_more</i>
</a>
</span>
</div>
<div class="body">
<div class="friend-list clearfix">
<ul>
<li class="active">
<span class="messages hide">
<span class="count"></span>
</span>
<img src="https://s5.postimg.org/3wnxyjz8n/image.png" alt="" />
<span class="name">
Jiffy
</span>
</li>
</ul>
</div>
<div class="chat-messages">
<div class="chat">
<div class="chat-content clearfix" >
<span *ngFor= "let message of messages_receiver" class="friend last">
{{message}}
</span>
<span *ngFor= "let message of messages_sender" class="you first">
{{message}}
</span>
</div>
<div class="msg-box">
<input type="text" [(ngModel)]= "message" class="ip-msg" placeholder="type something.." />
<span class="btn-group">
<a (click) = "send()" >
<i class="fa fa-paper-plane"></i>
</a>
</span>
</div>
</div>
</div>
</div>
</div>

Adjust the height of an element to match the height of another element in CSS

I have this code:
<div class="row">
<div class="box-body">
<div class="col-lg-12">
<div class="wrapper2">
<div class="col-xs-6">
<ul id="matchline-ul" class="todo-list matchline-options">
#foreach($question->answers as $answer)
#if($answer->is_key == 1)
<li id="matchline-static">
<span class="width-100" id="match-lines-options">
<input type="hidden" name="{{ $question->id }}[]" value="{{ $answer->order }}">
<div id="take-match-line-answer-text">
<span class="text padding-right-20">{!! $answer->text !!}</span>
</div>
</span>
</li>
#endif
#endforeach
</ul>
</div>
<div class="col-xs-6">
<ul class="todo-list">
#foreach($question->answers as $answer)
#if($answer->is_key == 0)
<li id="matchline-dynamic">
<span class="handle width-100">
<input type="hidden" name="{{ $question->id }}[]" value="{{ $answer->order }}">
<div id="take-order-answer-text">
<i class="fa fa-bars"></i>
</div>
<div class="float-left">
<span class="text padding-left-10">{!! $answer->text !!}</span>
</div>
</span>
</li>
#endif
#endforeach
</ul>
</div>
</div>
</div>
</div>
</div>
And the result of this is something like this photo:
I need cells on the left to match the height of cells on the right every time I move the cell up and down to be able the cell on left to be the same height as the one on right
Can someone please help me with this?
using tables instead of list or div will adjust the height and width automatically

Bootstrap is acting up from slight height pixel change

I'm using bootstrap for an easy responsive design. However, I moved computer today and was going to work on my project some more and my design is acting up (See attached figures). I have tested to see if I changed width, would it act up; no it did not. I then played with the height of my browsers to see if it did and yes it did act up and displayed improperly. I am fairly new-ish to bootstrap, but I am not sure what is causing this or could be on something on my computer end. I used Chrome for both viewing. I also tested with Edge and it displayed properly.
Look top-right for view port
This is what it should look like
This is what I get when changing resolution
At request, another part of the code which is loaded via JS.
<body>
<div id="interfaceNaviation" style="position:relative;top:0;left:0;right:0;background-color:green;">
<div class="navBar"><span class="navLink">Home</span> <span class="navLink">Presentation</span> <span class="navLink">Schedules</span> <span class="navLink">Display</span></div>
<br>
<div id="loginInfo">
<button id="signinButton" type="button" class="btn btn-primary btn-fixed-width navbar-btn" style="visibility: visible; display: inline;">
Sign in <i class="fa fa-white fa-sign-in icon-right"></i>
</button>
<a href="javascript:void(0);" id="signoutButton" class="navbar-nav" style="visibility: hidden; display: none;">
<span>Sign Out</span>
<i class="fa fa-blue-custom fa-sign-out"></i>
</a>
<div style="display:inline;" id="signinText">Authorize requests using OAuth 2.0:</div>
</div>
</div>
<div id="pres_interface" class="container-fluid" style="height:90%;">
<div id="pres_options" class="row" style="height:5%;">
<div id="add-placeholder" class="col-xs-2"><button id="btn_add-placeholder" class="btn btn-success fa-1.2x">Add Placeholder</button></div>
</div>
<!--style="left:0px;width:20%;height:100%;position:relative;"-->
<div id="pres_editor_panel" class="row" style="height:95%">
<div class="col-xs-2">
<div id="editor_display">
<div id="placeholderContainer"><span class="header fa-1.2x">Placeholders</span></div>
<li><span name="placeholders-change" class="fa-1.2x" data-id="ph1">ph1 <i data-id="void" class="fa fa-trash-o"></i></span></li>
<li><span name="placeholders-change" class="fa-1.2x" data-id="ph2">ph2 <i data-id="void" class="fa fa-trash-o"></i></span></li>
<li><span name="placeholders-change" class="fa-1.2x" data-id="ph04">ph04 <i data-id="void" class="fa fa-trash-o"></i></span></li>
<li><span name="placeholders-change" class="fa-1.2x" data-id="Test">Test <i data-id="void" class="fa fa-trash-o"></i></span></li>
<li><span name="placeholders-change" class="fa-1.2x" data-id="Test1">Test1 <i data-id="void" class="fa fa-trash-o"></i></span></li>
</div>
</div>
<!-- style="width:79.9%;height:100%" -->
<div class="col-xs-10 fa-padless-left">
<iframe id="fake_view" src="fake_view.html" style="width:100%;height:100%;border:1px solid #081D79;"></iframe>
</div>
</div>
</div>
<div id="pres_options-lower" style="background-color:purple;left:0;right:0;text-align:right;bottom:0;">
<button>Restore</button>
<button>Save</button>
<button>Publish</button>
</div>
<div id="window_mask" class="mask hidden"></div>
<div id="popup_display" class="hidden"></div>
<div id="sub_popup_display" class="hidden"></div>
<div id="sub_window_mask" class="mask hidden"></div>
</body>
This is my body code WITHOUT being edited via JS:
<body>
<div id="interfaceNaviation" style="position:relative;top:0;left:0;right:0;background-color:green;">
<div class="navBar"><span class="navLink">Home</span> <span class="navLink">Presentation</span> <span class="navLink">Schedules</span> <span class="navLink">Display</span></div>
<br /><div id="loginInfo">
<button id="signinButton" type="button" class="btn btn-primary btn-fixed-width navbar-btn">
Sign in <i class="fa fa-white fa-sign-in icon-right"></i>
</button>
<a href="javascript:void(0);" id="signoutButton" class="navbar-nav">
<span>Sign Out</span>
<i class="fa fa-blue-custom fa-sign-out"></i>
</a>
<div style="display:inline;" id="signinText"></div>
</div>
</div>
<div id="pres_interface" class="container-fluid" style="height:90%;" >
<div id="pres_options" class="row" style="height:5%;">
<div id="add-placeholder" class="col-xs-2"><button id="btn_add-placeholder" class="btn btn-success fa-1.2x">Add Placeholder</button></div>
</div>
<!--style="left:0px;width:20%;height:100%;position:relative;"-->
<div id="pres_editor_panel" class="row" style="height:95%">
<div class="col-xs-2">
<div id="editor_display" >
</div>
</div>
<!-- style="width:79.9%;height:100%" -->
<div class="col-xs-10 fa-padless-left">
<iframe id="fake_view" src="fake_view.html" style="width:100%;height:100%;border:1px solid #081D79;" ></iframe>
</div>
</div>
</div>
<div id="pres_options-lower" style="background-color:purple;left:0;right:0;text-align:right;bottom:0;">
<button>Restore</button>
<button>Save</button>
<button>Publish</button>
</div>
<div id="window_mask" class="mask hidden"></div>
<div id="popup_display" class="hidden"></div>
<div id="sub_popup_display" class="hidden"></div>
<div id="sub_window_mask" class="mask hidden"></div>
</body>
Thanks for any help! I am stumped at this right now.

I pasted this jsfiddle and it doesn't open the popup window

I have pasted a jsfiddle into my webpage and it doesn't work. Here is the jsfiddle. Pasted the CSS and javascript into the appropriaate places. There seem to be no errors on the console related to the link or popup.
All the link seems to do is to reload the current page.
Here is my HTML :
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-8">
<!-- POST -->
{% for entry in entries %}
<div class="panel panel-default">
<div class="panel-body">
<div class="media media-clearfix-xs-min">
<div class="media-left">
<a href="lesson.html">
<span class="media-object icon-block bg-default"><i class="fa fa-github"></i></span>
</a>
</div>
<div class="media-body">
<h3 class="media-heading h4">{{ entry.title }}</h3>
<p class="small text-muted">
<!-- <i class="fa fa-clock-o fa-fw"></i> time since post -->
Open PopUp
<div class="popup-box" id="popup-box-1">
<div class="close">X</div>
<div class="top">
<h2>Sample Header</h2>
</div>
<div class="bottom">
<p><h1>Sample Text</h1></p>
</div>
</div>
<i class="fa fa-user fa-fw"></i> {{entry.user_name}}
<i class="fa fa-calendar fa-fw"></i> {{entry.date_posted}}
</p>
{% for tag in entry.tagList %}
<span class="label label-default">{{tag}}</span>
{% endfor %}
</div>
</div>
</div>
</div>
{% else %}
<em>No entries!</em>
{% endfor %}
</div>
</div>
</div>
Sorry, here, I should have tested more.
I thought I had pasted the javascript in the right file, but I didn't. Once I pasted the js in the right file, it worked fine.