-1
I am with a doubt, I have a site style IFOOD, it contains a part of complements for the products, in the products there are the description, so I passed the description to the pop-up of the complements, follows the image
With this, in the button of "+" and less "-" it expands or decreases the description, however, I wonder if, has how to find out when the field does not exceed the width limit, because when not exceed, I want to remove the button of "+" and "-"
follows below my HTML code and my CSS:
<div class="text-container">
<div class="content hideContent">
%prod_desc%
</div>
<div class="show-more">
<a href="#" onclick="return false" id="mais">+</a>
</div>
</div>
<script>
$(".show-more a").on("click", function() {
var $this = $(this);
var $content = $this.parent().prev("div.content");
var linkText = $this.text();
if(linkText == "+"){
linkText = "-";
$content.switchClass("hideContent", "showContent", 400);
} else {
linkText = "+";
$content.switchClass("showContent", "hideContent", 400);
};
$this.text(linkText);
});
</script>
div.text-container {
margin: 0 auto;
width: 75%;
left: 50%;
}
.hideContent {
overflow: hidden;
line-height: 1em;
height: 2em;
margin-top: -3%;
margin-left: -17%;
}
.showContent {
line-height: 1em;
height: auto;
}
.showContent{
height: auto;
word-break: break-all;
margin-top: -3%;
margin-left: -17%;
}
.show-more {
text-align: center;
}
#mais{
float: left;
margin-left: 101%;
margin-top: -11.3%;
cursor: pointer;
color: var(--cor-secundaria);
font-size: x-large;
}