How to make indent of icon - html

I have a text and when I press on icon I can read more, and when press on another icon I can read less. The question is that how can make indent of top, for read more and read less icons to see them below than text, and make them(icons) in the center? The icons are +, -.
This is html:
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
<input id="read-more-state-1" class="read-more-state" type="checkbox">
<span class="read-more-target">
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages.
</span>
<label for="read-more-state-1" class="read-more-button">
<span class="read-more-button-icon"></span>
</label>
</p>
This is CSS:
.read-more-state {
display: none;
}
.read-more-button {
display: none;
}
#media only screen and (max-width: 600px) {
.read-more-target {
opacity: 0;
font-size: 0;
transition: .25s ease;
}
.read-more-button {
display: inline-block;
border-radius: 0.25em;
width: 1em;
height: 1em;
background: url(img/arrow%20grad.svg);
background-size: cover;
cursor: pointer;
}
.read-more-state:checked + .read-more-target {
opacity: 1;
font-size: inherit;
}
.read-more-state:checked ~ .read-more-button {
background: url(img/arrow%20up%20grad.svg);
background-size: cover;
cursor: pointer;
}
}

If you want the + and - icons to appear centered and below the text, your easiest option would be to make the p element positioned relative, and your icons positioned absolute.
p{
position: relative;
padding-bottom: 1.5em;
}
.read-more-button {
position: absolute;
bottom: 0px;
left: 50%;
}
Here is a codepen link.

Related

Contain text within width boundary of div in CSS

How can I contain the text to be within the width of my div and wrap to a new line in my css? Thank you!!
.render-message {
margin-top: 8px;
height: 90px;
margin-bottom: 8px;
}
.render-message {
margin-top: 8px;
height: 90px;
margin-bottom: 8px;
border: 1px solid red;
}
<div class="render-message">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived
not only five centuries, but also the leap into electronic typesetting, remaining essentially
</div>

Responsive tooltip in CSS

I have made a tooltip on hover over an icon and it works fine in desktop view.
Working Snippet:
.tooltip {
position: relative;
display: inline-block;
}
.tooltip img {
width: 15px;
}
.tooltip .tooltiptext[data-position="bottom"] {
visibility: hidden;
width: 400px;
background-color: #fff;
color: #000;
text-align: center;
border-radius: 0.5rem;
border-width: 1px;
border-color: #e2e8f0;
padding: 5px;
position: absolute;
z-index: 1;
top: 100%;
left: 50%;
margin-left: -60px;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
<label> Some Label </label>
<span className="ml-2">
<div class="tooltip">
<img
src="https://www.svgrepo.com/show/2297/doubts-button.svg"
alt="help text"
/>
<span data-position="bottom" class="tooltiptext">
Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever
since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. It has survived not only five
centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum.
</span>
</div>
</span>
Whereas in mobile view, this leads to horizontal scroll bar.
Please switch to mobile view to see the issue.
Things I tried:
I have tried removing margin-left and modified left value like,
.tooltip .tooltiptext[data-position="bottom"] {
visibility: hidden;
width: 400px;
.
.
.
.
.
left: 0%;
margin-left: 0px;
}
But this doesn't work... Kindly please help me to make this tooltip responsive in mobile devices using CSS. Big thanks in advance.
Just add the following css:
#media screen and (max-width: 576px) {
.tooltiptext {
width: 300px;
}
}

Set height based on fixed siblings

I have some code that works almost perfectly. I have the following requirements:
A banner with the same text fixed to the top and bottom of the viewport.
childContent should scroll when the contents overflow beyond the available space without moving the banners
The scroll bar is positioned within #contentContainer, not the entire viewport.
The #window-container div should be able to live in any size div in the viewport. It will not always fill the screen.
If you were to change the numberOfParagraphs and your viewport as it is now, this works perfectly.
https://codepen.io/anon/pen/QYVNbd
However, the banner text is going to be a variable length. Using calc(100% - 3em) doesn't work when there is more than one row of text because the height of the two banners is now 6em. You can see this by un-commenting line 7 of the JS. The bottom banner is now pushed off the screen.
How do I keep the bottom banner from being pushed off the screen when there is more than 1 line of text in the banners?
I have searched far and wide, and calc(100% - 3em) is the answer I keep coming back to.
If at all possible, I'd like to figure out a pure HTML/CSS solution and not include js/jquery.
Final Solution
https://codepen.io/anon/pen/yZxrmg
This is mostly kukkuz's solution using the flexbox. I also added a relative font size to the banners so it wouldn't overtake the content when the overall size is much smaller.
You can play around with the number of paragraphs and verify the banner stays at the bottom of the viewport. Also, horizontal scroll works perfectly too. (uncomment line 23).
You can use a flexbox layout here:
Make your window-container a column flexbox with viewport height (you can remove the calc height set on contentContainer and add flex: 1)
Also set margin: 0 to the body element to reset the default margin and preventing margin collapsing with the margin of the p elements inside.
See demo below:
var bannerText = "Demo Application";
var numberOfParagraphs = 8;
/**
* Change the length of the banner so it runs to the second line
* You might need to adjust your screen width
*/
bannerText = "Fixed Alert with super long footer that will eventually run off the screen and onto the next line. If we don't handle this, the footer will get pushed off the screen";
var banners = document.getElementsByClassName("bar-text");
for (var i = 0; i < banners.length; i++) {
banners[i].innerHTML = bannerText;
}
// This just generates an amount of paragraphs to test the vertical resizing
var text =
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
var returnArray = ["<p>" + text + "</p>"];
/**
* Check how horizontal scrolling looks
* The content moves, but the banners stay fixed
*/
// returnArray = ['<p style="width: 200%">' + text + '</p>']
for (var i = 1; i < numberOfParagraphs; i++) {
returnArray.push("<p>" + text + "</p>");
}
document.getElementById("childContent").innerHTML = returnArray;
body {
margin: 0; /* ADDED */
}
.window-container {
position: fixed;
height: 100vh; /* ADDED */
display: flex; /* ADDED */
flex-direction: column; /* ADDED */
}
.navbar {
position: relative;
padding: 0;
background: grey;
width: 100%;
}
.bar-text {
margin: auto;
color: white;
font-family: Arial, Helvetica, sans-serif;
text-align: center;
}
#contentContainer {
position: relative;
overflow: auto;
flex: 1; /* ADDED */
/*height: calc(100% - 3em);*/
/* For non-scrolling content */
/* overflow: hidden; */
}
#childContent {
padding: 0.5em;
}
<div class="window-container">
<div class="navbar">
<div class="bar-text"></div>
</div>
<div id="contentContainer">
<div id="childContent">
</div>
</div>
<div class="navbar">
<div class="bar-text"></div>
</div>
</div>
You can easily do this by using position:sticky to both header and footer of your code.
Javascript code isn't necessary I just used it to create a dynamic header & footer.
You can find the updated pen here.
var paraNum = 15;
var content =
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
function repeat(paraNum, content) {
for (i = 0; i < paraNum; i++) {
paraCount = i + 1;
document.getElementById("contentContainer").innerHTML =
document.getElementById("contentContainer").innerHTML +
"<p>" +
paraCount +
") " +
content +
"</p>";
}
}
repeat(paraNum, content);
function addElement(parentId, elementTag, elementId, html) {
var p = document.getElementById(parentId);
var newElement = document.createElement(elementTag);
newElement.setAttribute("id", elementId);
newElement.innerHTML = html;
p.appendChild(newElement);
}
function removeElement(elementId) {
var element = document.getElementById(elementId);
element.parentNode.removeChild(element);
}
body {
display: flex;
flex-direction: column;
background: #222;
height: 85vh;
align-items: center;
justify-content: center;
font-family: monospace;
}
.windowContainer {
background: rgba(222, 222, 222, 0.3);
width: 80%;
height: 70%;
overflow-y: scroll;
}
#contentContainer {
color: #ddd;
padding: 0 1em;
position: relative;
z-index: 2;
}
#contentHeader {
text-align: center;
color: #222222;
background: #dddddd;
position: sticky;
top: 0;
z-index: 5;
}
#contentFooter {
text-align: center;
color: #222222;
background: #dddddd;
position: sticky;
bottom: 0;
z-index: 5;
}
input {
width: 200px;
}
<input type="button" onclick="addElement('contentHeader', 'div', 'fixedHeadingLine','Header Line');" value="Add a Header Line" />
<input type="button" onclick="removeElement('fixedHeadingLine');" value="Remove a Header Line" />
<div class="windowContainer">
<div id="contentHeader">Header Line</div>
<div id="contentContainer">
Content Heading
</div>
<div id="contentFooter">Footer Line</div>
</div>
<input type="button" onclick="addElement('contentFooter', 'div', 'fixedFooterLine','Footer Line');" value="Add a Footer Line" />
<input type="button" onclick="removeElement('fixedFooterLine');" value="Remove a Footer Line" />
Please do note that removing the original Header/Footer using the
buttons throws an error.
I hope you find this helpful.
Peace 🖖

Display text below price

If you visit this link, you can see below image at the center of the page:
On this site, if you mouse over currency symbol present on top right of window, you can see drop down options, once you change a dropdown option, you can see "Usually Delivered in 3-5 business days" text next to price - I want this text below the Price, as in the next image:
This is the CSS I am using and, it doesn't matter how I try, can't get the desired result. Can someone please have an advice for me? Thank you.
font-family: 'Roboto Condensed', sans-serif;
color: #636363;
font-size: 14px;
line-height: 1.5;
}
on
.price-info
Take off
max-width: 31%;
So that it takes up the entire line
Try taking the float:left off of your p tag. That should fix a few issues on your page and might fix the issue you're having with the text displaying in the wrong area.
You should probably also add some html and css to your question. Without it it makes it a hassle to answer.
$(document).ready(function() {
$('.qty-btn').click(function(){
if($('.qty').val() > 0)
{
$('.deliveryMsg').text('Usually Delivered in 3-5 days.');
}else {
alert("Qty must be greater than 0");
}
});
});
body {
background: silver;
}
.section {
height: 400px;
width: 500px;
margin-bottom: 20px;
background: #FFFFFF;
margin-left: 100px;
padding: 10px;
}
/* used for demo purposes */
.product-img {
background: silver;
opacity: 0.5;
height: 150px;
width: 150px;
/* center the img within the col */
display: block;
margin: auto;
}
.col-left {
width: 40%;
}
.col-right {
float: right;
margin-top:-165px;
text-align: left;
width: 60%;
}
.title {
font-weight: bold;
}
.price {
margin-top: -5px;
margin-bottom: -5px;
color: blue;
}
input[type="text"] {
width: 50px;
}
span {
font-size: small;
font-weight: bold;
}
input[type="button"] {
background: orange;
color: #FFFFFF;
}
.qty {
width: 20px !important;
}
.wishlist {
width: 130px !important;
}
.deliveryMsg {
font-weight: bold;
opacity: 0.5;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="section">
<div class="col-left">
<div class="product-img"></div>
</div>
<div class="col-right">
<p class="title" >Golden Waves Marble Texture Apple IPhone 4 Phone Case</p>
<hr />
<ul>
<li>Device: Apple iPhone 4</li>
<li>Design: Marbles</li>
<li>Material: Polycarbonate Hard Case</li>
</ul>
<hr />
<h3 class="price">499.00</h3>
<hr />
<form>
<span>Check Delivery Availability <input type="text" placeholder="Enter PIN Code" /> <input type="button" value="CHECK" /></span>
<br /><br />
<span>Qty: <input class="qty" type="text" /> <input class="qty-btn" type="button" value="ADD TO CART" /> <input class="wishlist" type="text" placeholder="SAVE TO WISHLIST" /></span>
<br /><br />
<span class="deliveryMsg"></span>
</form>
</div>
</div>
<div class="section">
<h2>Product Description</h2>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
Hope that helps!

How to wrap one div id around another one?

How to wrap one div around another? I have following two div ids:
#course {
width: 325px;
padding-right: 25px;
border-right: 1px solid #999;
border-top: 1px solid #999;
}
#home-page-sign-up {
width: 275px;
#padding-left: 25px;
float: right;
margin: auto;
#position: relative;
display: block;
clear: both;
}
I want #course to be on left and #home-page-sign-up on right just next to it. I do get block on left and right as assigned but one is below another, I want them to be side by side.
How can I achieve it?
You will want to float both of them left:
#course{
float:left;
width:325px;
padding-right:25px;
border-right:1px solid #999;
border-top:1px solid #999;
}
#home-page-sign-up {
width:275px;
#padding-left:25px;
float:left;
margin: auto;
#position:relative;
display:block;
}
Just make sure #course falls first in the html
Try this:
#course{
width:325px;
float:left;
padding-right:25px;
border-right:1px solid #999;
border-top:1px solid #999;
}
#home-page-sign-up {
width:275px;
#padding-left:25px;
float:left;
margin: auto;
#position:relative;
}
Then, in your body tags, do:
<div id="course">Course Div Content here...</div>
<div id="home-page-sign-up">Home Sign-up Content here...</div>
<div style="clear: left;"></div>
That's one way...that hopefully works ;)
I dont know what you mean by "wrap around" but if you want the divs to be next to each other, put float: left; in both styles...
see fiddle for code and demo
Fiddle: http://jsfiddle.net/t4LUF/3/
Demo: http://jsfiddle.net/t4LUF/3/embedded/result/
NOTE: For demo purpose i gave border to all div's you can change as per your need.
HTML:
<div id="big-container">big-container
<div id="container">
<div id="course">course Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
<div id="home-page-sign-up">home-page-sign-up </div>
</div>
</div>
SS: http://img812.imageshack.us/img812/3783/divcontainersidebyside.jpg