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.
Related
I have a breadcrumb which I need to cut / shorten the breadcrumb if it's too long with text-overflow css. I have tried and confused to make a different color link only in last breadcrumb. In my breadcrumb, max breadcrumb to show is 4.
From the code below, I success to shortened breadcrumb using text-overflow: ellipsis. Like if breadcrumb have 4 link, I using foreach to show breadcrumb that index number 2 and index number 3 is too long, I shortened them using text-overflow: ellipsis. If the breadcrumb have 3 link, I used same looping too.
I want to ask how can I make different color text / link only in the last breadcrumb like if breadcrumb have 3 link, index number 2 is have different color than others. And if breadcrumb have 4 link, index number 3 is have different color ?
Here's the html code
<?php if (isset($breadcrumbs)): ?>
<?php
$numItems = count($breadcrumbs);
$i = 0;
//echo $numItems;
?>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb): ?>
<?php if ($i == 0 || $i == 1): ?>
<li class="breadcrumb-item"><?= $breadcrumb['text'] ?></li>
<?php else: ?>
<li class="breadcrumb-item"><?= $breadcrumb['text'] ?> </li>
<?php endif ?>
<?php $i++; ?>
<?php endforeach ?>
</ol>
</nav>
<?php endif ?>
Here's the css code
.breadcrumb {
padding: 5px 0px;
margin-bottom: 0px;
background-color: #ecf0f5;
}
.breadcrumb-item+.breadcrumb-item::before {
content: ">";
font-size: 12px;
}
.breadcrumb-item {
font-size: 14px;
}
.breadcrumb-item .last{
display: inline-block;
width: 100px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
line-height: 10px;
}
.breadcrumb-item a{
color: #535353;
}
.breadcrumb-item:hover > a{
color: #1787fa
}
.mini-breadcrumb{
display: none;
}
Thank you
Try this css on your .breadcrumb-item:
.breadcrumb-item:last-of-type a{
color: grey;
}
use your desired color instead of grey.
You can also use :last-child selector.
.breadcrumb-item:last-child a {
color: grey;
}
Just adding another link where you can find difference between type-of and child difference.
What is the difference between :first-child and :first-of-type?
What I want:
1:
What I want is that the echo '<span class="badge bg-red">Denied</span>'; is directly under the echo '<b> '</b>'; and that the img is the full height. And if I use the <br> it puts the text under the img and not next to it. Because I need the image to be always on the left with the text next to it.
2: The second thing that I want is that there is a small line under the
echo '<b> '</b>';
echo '<a> - ' . $topic['voornaam'] . '</a>';
How it looks like now.
The code:
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title"><b>Topics</b></h3>
</div><!-- /.box-header -->
<div class="box-body">
<?php
$toppic = $app->get_topics();
foreach($toppic as $topic){
echo '<div id="topic">';
if(file_exists('assets/images/profielfotos/'.$topic['klant_id'])) {
echo '<img style="height:100%;"class="img-circle" src="/assets/images/profielfotos/'.$topic['klant_id']src="###.'/'.$topic['foto'].'"###'" />';
} else {
echo '<i class="fa fa-fw fa-user img-circle"></i>';
}
echo '<b> '.$topic['topicnaam'].'<$####'</b>';
echo '<a> - ' . $topic['voornaam'] ####. " " . $topic['achternaam']#### . '</a>';
echo '<span style="float:right;"class="fa-stack"><span class="fa fa-comment-o fa-stack-2x"></span><strong class="fa-stack-1x" style="font-size:10px;">999</strong></span>';
echo '<span class="badge bg-red">Denied</span>';
echo '</div>';
}
?>
</div><!-- /.box-body -->
<div class="box-footer text-center">
</div><!-- /.box-footer -->
</div><!-- /.box -->
The custom css:
#topic a {
color: black;
margin-left: 1%;
}
#topic {
padding: 10px;
}
#topic i{
font-size: 2.3em;
width: 33px;
}
One of the alternatives is by using the list tag
Here is an example for your convenience:
HTML:
<ul>
<li>
<img src="https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/68dd54ca-60cf-4ef7-898b-26d7cbe48ec7/10-dithering-opt.jpg" class="pic">
</li>
<li>
<h2>Title</h2>
<p>description declined</p>
</li>
</ul>
CSS:
.pic{
max-width:150px;
max-height:150px;
margin-right:50px;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 16px;
text-decoration: none;
}
ul {
list-style-type: none;
}
.pic{
max-width:150px;
max-height:150px;
margin-right:50px;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 16px;
text-decoration: none;
}
ul {
list-style-type: none;
}
<ul>
<li>
<img src="https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/68dd54ca-60cf-4ef7-898b-26d7cbe48ec7/10-dithering-opt.jpg" class="pic">
</li>
<li>
<h2>Title</h2>
<p>description declined</p>
</li>
</ul>
Adjust it accordingly with your code. Have fun :)
First of all, there's some sintax errors at the php code in the <div class="box-body">, check it out because the compiler can throw an error.
At the css part, i would use position: relative to the DOM elements inside the <div class="topic"> and later adjust it with top, bottom, left, right (Check this out for more info about the positioning properties in css).
Also, i would set the image full height with height: 100%, but, just as a recommendation, try using height: auto, with this property the img height adjusts to the DOM and it MAYBE get a height you like(Here's some info about height property).
Finally, you could get the small line with the <u> html tag or with the css text-decoration: underline. You can see both here.
Hope this answer helps you, if it does, please vote it up so that people can get helped if needed :)
I have a problem with an unordered list when I insert a variable inside an image.
Please have a look at this fiddle.
So basically, what I get here is a list of images, centred and floated to the left, with left alignment on new lines as well.
In Jsfiddle I used a random image. When I copy this code exactly as it is into my code it works fine. When I swap the random image to a PHP variable the whole list jumps around and it looks very bad. Allow me to illustrate what I see with a PHP variable inserted:
I have no idea why this becomes like this. Here is my code with the PHP variable:
<div class="snaps-wrap">
<ul>
<?php
//Here is php code which works fine
?>
<li>
<a href="#">
<img id="snap-img" src="<?php echo $snappic?>" alt="">
</a>
</li>
<?php }
}
?>
<p style="clear: both;"></p>
</ul>
</div>
Here is CSS:
.snaps-wrap {
width: 70%;
margin: 0 auto;
padding: 0;
}
.snaps-wrap ul {
padding: 0.5em 0;
text-align:center;
margin:0 auto;
background:#ddd;
list-style: none;;
}
.snaps-wrap ul li {
float: left;
width: 25%;
margin: 0.5em 0;
}
#snap-img {
width: 150px;
}
As I mentioned, with the image used in jsfiddle this works fine, as soon as I change the image source to my variable it becomes misplaced.
Any ideas why this happens and how to fix this?
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%;
}
Building my first website, and learning HTML, CSS, PHP, MySQL as needed. I'd like a set of inline divs which are aligned to the left. However, if there's not enough room to fill the screen, I'd like for the entire block of inline divs to be centered. After much searching and research, I determined it was impossible with only CSS, due to the fact that the internal size of all the inline left aligned divs would have to be calculated before the auto margin of the centered containing div could be calculated. I ended up kludging it together with the use of a whole bunch of invisible inline "ghost" divs which make the last line of the inline divs appear as if it's left-aligned.
Now it looks like this, which is great. http://i.stack.imgur.com/Zmru7.png
I gave the fake divs a border, and now they're visible. http://i.stack.imgur.com/Zmru7.png
Firstly, is there an elegant solution to this aside from media tags which change the CSS depending on screen size? Secondly, is it possible to force it to center when there's only one line?
i.stack.imgur.com/ DjWaj.png
CSS: (stripped, if something seems missing let me know)
div.pmegaframe {
width: 100%;
margin: 0px auto; padding: 0px;
text-align: center; }
div.pfake {
display: inline-block;
vertical-align: top;
overflow: hidden;
margin: 22px; margin-top:0px; margin-bottom:0px;
width: 164px; height: 1;
border: none; }
div.pframe {
display: inline-block;
vertical-align: top;
overflow: hidden;
margin: 15px;
width: 164px;
border: 6px solid var(--header); }
/*div.pframe:hover {
border: 16px solid #B85843; }*/
div.pminiframe {
width: 160px;
margin: 0px; padding: 0px;
border: 2px solid var(--white);
background: var(--dark); }
div.pimageframe {
overflow: hidden;
width: 160px; height: 160px;
color: var(--accent);
background: var(--white); }
div.pwordsframe {
position: relative;
width: 160px; height: 280px; }
index.php (stripped)
<div class="pmegaframe">
<?php
$pquery = mysqli_query($db, "SELECT f_name, l_name, blurb FROM users");
$pnum = mysqli_num_rows($pquery); $id = 0; //Pull userdata
while ($id < $pnum) { //Collect userdata
mysqli_data_seek($pquery, $id); $prow = mysqli_fetch_row($pquery);
$image = "160px_profile_".$id; $name = $prow[0]." ".$prow[1];
$text = $prow[2];
$state = 0; $rating = 1;
$squery = mysqli_query($db, "SELECT ID, courseID FROM subjects WHERE userID=".$id); //Pull the user's subjects
$snum = mysqli_num_rows($squery);
include "pframe.php"; //Makes the userframe
$id += 1;
}
echo str_repeat("<div class=\"pfake\"></div>", 8);
//fills in the grid with invisible boxes
?>
</div>
pframe.php (also stripped):
<div class="pframe"> <!--The base grey outer frame-->
<a href="profile.php?user=<?php print $id?>" class="nocolor"> <!-- links it-->
<div class="pminiframe"> <!-- puts down the interior white frame-->
<div class="pimageframe"> <!--The upper half of the box-->
<img src="/profiles/<?php echo $image; ?>.png" alt="Profile image not found!"></div>
<div class="pwordsframe"> <!--The lower half of the box-->
<!-- *snip* This was the messy content of the lower half of the profile boxes. -->
</div>
</div>
</a>
</div>