I have a block from 3 elements - minimum value, stock of a product, maximum value.
All i need to do is to find a way to align the stock of the product in the middle between both values.
My guess is that the problem should be somewhere on these lines:
<style>
.inline-parent{text-align:center;}
.inline-block{display:inline-block;margin-right:10px;}
</style>
<div class="max inline-parent">
<div class="inline-block"><?php echo $tickets_sold;?></div>
<div class="inline-block"><?php echo $max_tickets;?></div>
</div>
My browser renders the file like this:(screenshot)
Inspect of the element shows this: (screenshot)
Using Flex wrong
even worst
CSS -
.wcl-progress-meter meter::-webkit-meter-suboptimum-value {
box-shadow: 0 5px 5px -5px #999 inset;
background: #cb132b;
display:inline-block;
}
.wcl-progress-meter .zero {
display: inline-block;
position: absolute;
top: -100%;
}
.wcl-progress-meter .min {
display: inline-block;
position: absolute;
top: -100%;
}
.wcl-progress-meter .max {
display: inline-block;
position: absolute;
top: -100%;
right: 0;
}
PHP- file where i tried to edit the code
$max_tickets = $product->get_max_tickets();
$tickets_sold = wc_get_stock_html( $product );
<div class="wcl-progress-meter <?php if($product->is_max_tickets_met()) echo 'full' ?>">
<progress max="<?php echo $max_tickets ?>" value="<?php echo $lottery_participants_count ?>" low="<?php echo $min_tickets ?>"></progress></br>
<span class="zero">0</span>
<style>
.inline-parent{text-align:center;}
.inline-block{display:inline-block;margin-right:10px;}
</style>
<div class="max inline-parent">
<div class="inline-block"><?php echo $tickets_sold;?></div>
<div class="inline-block"><?php echo $max_tickets;?></div>
</div>
CSS flexbox will help you achieve this easily.
Check this fiddle
Read about CSS flex
.value-container{
width: 600px;
display: flex;
justify-content: space-between;
}
UPDATE:
Make sure you take out the span from wcl-progress-meter div and put it inside max div
You can also get rid of inline-block class. Refer below Code.
<span class="zero">0</span>
PHP:
<div class="max">
<span class="zero">0</span>
<div><?php echo $tickets_sold;?></div>
<div><?php echo $max_tickets;?></div>
</div>
CSS:
.max{
display: flex;
justify-content: space-between;
}
UPDATE : 2 (Below CSS should work if you remove the absolute position)
.wcl-progress-meter meter::-webkit-meter-suboptimum-value {
box-shadow: 0 5px 5px -5px #999 inset;
background: #cb132b;
display:inline-block;
}
.wcl-progress-meter .zero {
/* try removing the CSS */
}
.wcl-progress-meter .min {
/* try removing the CSS */
}
.wcl-progress-meter .max {
display: flex;
justify-content: space-between;
}
Related
I'd like to attach a label to the images on my website, so I used the following CSS and HTML code.
CSS:
/* Image */
.image {
border: 0;
display: inline-block;
position: relative; }
.image::after {
content: "Photo credit: Me";
position: absolute;
bottom: 0;
right: 3em;
font-size: 0.7em;
color:rgba(0, 0, 0, 0.175)}
.image img {
display: block; }
.image.left, .image.right {
max-width: 30%; }
HTML:
<div class="row">
<p>
<span class="image left">
<img src="images/image_1.png">
</span>
</p>
</div>
The code above works perfectly but I don't always want to show "Photo credit: Me" on my images. Instead, I want to set "Photo credit: Me" as a default text but show different text when specified. I tried using attr like below:
/* Image */
.image {
border: 0;
display: inline-block;
position: relative; }
.image::after {
content: attr(data-content, "Photo credit: Me"); /*<--Modified */
position: absolute;
bottom: 0;
right: 3em;
font-size: 0.7em;
color:rgba(0, 0, 0, 0.175)}
.image img {
display: block; }
.image.left, .image.right {
max-width: 30%; }
<div class="row">
<p>
<span class="image left">
<img src="images/image_1.png" data-content="Photo credit: Others">
</span>
</p>
</div>
However, this code does not show anything on the images. What am I doing wrong?
Note: I'm using a template downloaded from https://html5up.net/editorial . There is a chance that some properties defined elsewhere in CSS are causing this issue...
first, you shoud put the data-content on span, because the class .image is on span.
second, till 2022-12-17, browser only supports basic attr() method, no one support fallback feature. if you want to implmenet fallback feature, you can use var to work around.
please check the code below:
css
/* Image */
.image {
border: 0;
display: inline-block;
position: relative;
}
.image[data-content] {
--test : attr(data-content); /* if image have data-content, then we defined the variable test) */
}
.image::after {
content: var(--test, "Photo credit: Me"); /*if var test not be define, we use default value */
position: absolute;
bottom: 0;
right: 3em;
font-size: 0.7em;
color:rgba(0, 0, 0, 0.175)}
.image img {
display: block; }
.image.left, .image.right {
max-width: 30%; }
html
<div class="row">
<p>
<span class="image left" data-content="Photo credit: Others">
<img src="images/image_1.png">
</span>
</p>
</div>
I'm trying to set the toggle buttons to the right. float, right : 0, align-self is not working for me.
What am I doing wrong ?
The picture is at the end.
HTML:
<div if:true={showCards} class='main-container'>
<div class="main-container-top">
<p class="currs-available"> {trainingPlans.length} {headerLabel} </p>
<lightning-input
class="search slds-p-vertical_small"
type="search"
onchange={handleSearch}
variant="label-hidden"
placeholder="Search" >
</lightning-input>
<c-toggle-button
class="toggle"
buttons={toggleData}
ontoggleswitch={handleToggleSwitch}
default=1>
</c-toggle-button>
</div>
.............
......
.....
and relevant CSS:
.main-container{
background: #f5f5f5;
}
.main-container-top{
display: flex;
}
.currs-available{
width: 33%;
font-size: 20px;
font-weight: 700;
padding: 9px 0 0 20px;
}
.toggle{
width: 33%;
}
Image of element
You can use position: absolute; if you're using right: 0;
Although, the display: flex; will be ignored
we can see lot of empty space in link as below the image. I want to hide those empty space.
.main {
margin: 0 auto;
width: 1000px;
}
body, button, input, select, table, textarea {
font-family: 'Roboto Condensed', sans-serif;
color: #636363;
font-size: 14px;
line-height: 1.5;
}
html
<div class="custom_case">
<div class="custom_case_left">
<h1 class="cc1">Custom Cases</h1>
<h2 class="cc2">Make Your Own design</h2>
</div>
<?php
$brandSelect = '<select id="brand_select">';
$brandSelect .= '<option value="">My Brand</option>';
$brandSelect .= '</select>';
echo '<select id="model_select"><option value="">My Model</option></select>';
?>
<div class ="cc3">
<div class ="cc4">
<span class ="cc5"> See Cases > </span>
</div>
</div>
I dont want to give so much empty space between image and below footer
please help me for this.
Thanks in advance.
Figured it out for you!
Your image of the phone cases is what is causing the space issue.
.custom_case_right img {
/*float:right;*/
/*bottom:320px;*/
}
That will fix the spacing beneath your image. Now your image is displaying improperly and to fix do this
.custom_case_right {
float:right;
margin-top:-310px;
}
These two changes ought to take care of it for you. I tested this out in Chrome.
You'll still need to think about how you want to have your image behave as your viewport shrinks though.
trying to make img:
line-height: 0;
vertical-align: top or bottom;
You have to fix the height of main-container.
enter code here.main-container{
height:550px;
}
Make this changes to your classes:
.col1-layout .col-main {
position: relative;
}
.custom_case_right {
float: left;
position: absolute;
top: 0;
bottom: 0;
right: 0;
}
And in your image remove position absolute, add this style instead:
.custom_case_right img {
position: relative;
width: 620px;
height: 100%;
}
I'm working on "Related Articles" widget carousel navigation in WordPress. Widgets is working fine and now I'm working on styling part.
This is what I currently have:
This is what I want to achieve:
The problem is that I'm stuck on styling li. The problem is that I'm trying first of all to add width and height even with !important and it's still not re-sizing. So I need to split this carousel navigation into 8 similar parts. I think display:inline / display:inline-block might cause this issue.
CSS:
div.carousel_navigation {
display: inline-block;
background: #eeebe7;
width: 224px;
position: relative;
border-right: 1px solid #b1afa9;
border-left: 1px solid #b1afa9;
border-bottom: 1px solid #b1afa9;
}
ul li.prev-article, ul li.next-article {
display: inline;
width: 28px;
height: 20px;
}
li.nav-item-links {
display: inline;
width: 28px;
height: 20px;
}
PHP:
<div class="carousel_navigation">
<ul>
<li class="prev-article"><a class="prev-article"><</a></li>
<?php $count = 1; foreach( $related_posts_guides as $post): // variable must be called $post (IMPORTANT) ?>
<li class="nav-item-links">
<a href="#item_<?php echo $count; ?>">
<?php echo $count; ?>
</a>
</li>
<?php $count++; endforeach; ?>
<li class="next-article"><a class="next-article">></a></li>
</ul>
</div><!-- .carousel_navigation -->
Thank you in advance!
That's because your li elements are inline. If you want them to be in line with eachother, but also stylable with properties like height and width, you'll need to set them as inline-block instead:
ul li.prev-article, ul li.next-article,
li.nav-item-links {
display: inline-block;
width: 28px;
height: 20px;
}
Note that I've also joined both of your selectors with a comma as their style properties were identical.
I have a sentence in h1 tag. On resize I want the last three words to jump down together not just one at a time, since the last three words are a tagline and it wouldn't make sense if they get separated. Here is the live site.
Here is the HTML:
<header class="header" role="banner">
<div id="inner-header" class="wrap clearfix">
<div id="title">
<!-- to use a image just replace the bloginfo('name') with your img src and remove the surrounding <p> -->
<h1 id="logo" class="h1">
<a href="<?php echo home_url(); ?>" rel="nofollow">
<?php bloginfo('name'); ?><span class="subtitle">
<?php bloginfo('description'); ?></span>
</a>
</h1>
</div>
<nav role="navigation">
<?php bones_main_nav(); ?>
</nav>
</div> <!-- end #inner-header -->
and the scss:
.header {
#title {
#include span-columns(23 ,24);
position: absolute;
top: 30px;
text-align: center;
}
.subtitle {
font-size: 0.3em;
margin-left: 1em;
}
.nav {
#include span-columns(24 omega ,24);
margin-top: 289px;
}
#logo {
a {
color: #fff;
font-family: 'Pacifico', cursive; /*font-size: 2.5em;*/
text-shadow: 0px 0px 0 #B6CEBF,
0.707px 0.707px 0 #B6CEBF,
1.414px 1.414px 0 #B6CEBF,
2.121px 2.121px 0 #B6CEBF,
2.828px 2.828px 0 #B6CEBF,
3.536px 3.536px 0 #B6CEBF,
4.243px 4.243px 0 #B6CEBF,
4.95px 4.95px 0 #B6CEBF,
5.657px 5.657px 0 #B6CEBF,
6.364px 6.364px 0 #B6CEBF,
7.071px 7.071px 0 #B6CEBF;
}
}
}
Try this:
.subtitle {
display: inline-block;
font-size: 0.3em;
margin-left: 1em;
}
Setting the display to inline-block will keep the element's contents together (a behavior of block elements), but still keep it inline with other text.
You should also look at making some other adjustments so the title can be 100% width, and the navigation still gets positioned properly:
#logo {
margin: 80px 0 0;
}
.header #title {
height: 289px;
overflow: hidden;
position: relative;
text-align: center;
width: 100%;
}
.header .nav {
display: inline;
float: right;
width: 100%;
}
.header .nav ul {
/* Add the .clearfix class to this ul */
}
We are talking about responsive #media queries here. There are few ways to do this, but this is the fastest:
Add this rule to you scss:
#media only screen and (max-width: 768px) {
.subtitle{
display: block;
}
}
Aside
Bones comes with other scss files, edit _base.scss for general styles, but for custom styles on resize edit files like _768up.scss, also read the info inside the style.scss file to get more info about the media queries. Bones comes with an awesome documentation.
Further reading
Nice tutorial about media queries from CSS-tricks
Media Queries Spec from W3C
CSS media queries at MDN