I'm using images as bulletpoints for my Github Pages (markdown files), as described here. Now, I'd like to center the text next to the image vertically. This is shown here (cf. lower third of page), but I have to do it with inline css and cannot get it to work.
What I have so far:
<ul style="list-style-image: url('/assets/images/thumb.jpg'); padding-left: 120px;">
<li>I’m writing a long list item 1 so you can see what happens when the text wraps across multiple lines</li>
</ul>
gives me
when I'd ideally want it to look like:
I already tried setting the line height, but this results in weirdness when there's a linebreak, as is the case here. I read about flexbox, but am unsure how to use it inline. Any help is appreciated!
I repeat: IT MUST BE INLINE !!
Why don't use in your HTML something like this:
<div class='list-item'>
<img src='/assets/images/thumb.jpg' class='bullet-image'/>
<p class='item-text'>Lorem ipsum...</p>
</div>
And then in your CSS you could add:
.list-item {
display: flex;
align-items: center;
justify-content: center;
}
That should do the trick. Then you can re-size the image as you like.
EDIT:
Another thing you can do, using inline styles is something like this:
<ul>
<li style="display: flex; justify-content: center; align-items: center">
<img src='/assets/images/thumb.jpg' style=""/>
<p> I’m writing a long list item 1 so you can see what happens when the text wraps across multiple lines </p>
</li>
</ul>
Then you should resize the image to the size you like by adding the width and height properties on the style attribute of the img element
Related
this is text that overlaps itself
I am currently trying to use a flex box with columns made the height of the first column 100% so that it would force the other two boxes to be on top of each other. In the first box I typed artistry by and in the second and third I’m trying to align the text so that they can have LE and XI directly over each other. Any advice here would help.
Can you post your code? You may be missing some containers so you can have better control. I haven't tested this, but this example might guide you.
HTML:
<div class="logoContainer">
<h1> artistry by </h1>
<div class="rightSideOfLogo">
<h1>LE</h1>
<h1>XI</h1>
</div>
</div>
CSS:
.logoContainer {
display: flex,
flex-direction: row
}
.rightSideOfLogo {
display: flex,
flex-direction: column
}
I have a three even columns using flexbox. In CodePen it looks more clear: https://codepen.io/pixy-dixy/pen/KKVwvoQ
Here is the code:
.rowIdeas {
text-align: center;
display: flex;
justify-content: space-around;
flex-direction: row-reverse;
}
.columnIdeas {
flex-basis: 25%;
}
.maxSize {
max-height: 300px;
}
<!-- about ideas section start -->
<div class="rowIdeas">
<div class="columnIdeas iransansdnlight">
<div>
<img class="maxSize" src="https://langfox.ir/vc/philosophy.svg">
<h2>Item one</h2>
<p>Flex items do not need to be block level unless the content they contain requires it. Also, you've prefixed all of the display properties, but didn't prefix any of the other Flexbox properties (which have different names in the other drafts).</p>
</div>
</div>
<div class="idea columnIdeas iransansdnlight">
<div>
<img class="maxSize" src="https://langfox.ir/vc/idea.svg">
<h2>item two</h2>
<p>Flex items do not need to be block level unless the content they contain requires it. Also, you've prefixed all of the display properties, but didn't prefix any of the other Flexbox properties (which have different names in the other drafts).
</div>
</div>
<div class="columnIdeas iransansdnlight">
<div>
<img class="maxSize" src="https://langfox.ir/vc/results.svg">
<h2>item three</h2>
<p>Flex items do not need to be block level unless the content they contain requires it. Also, you've prefixed all of the display properties, but didn't prefix any of the other Flexbox properties (which have different names in the other drafts).</p>
</div>
</div>
</div>
<!-- about ideas section ends -->
The code works fine here and in CodePen, but when I put the same code in my landing page, I see this:
As you see the first one goes a bit upper than others.
Any idea what the problem is?
The problem is that the svg images are differnt proportions. So the one on the left is actually shorter, so the title doesn't drop as low as the others. You'll have to either give them a specific height, remake it so they're all the same height, or otherwise account for the varying sizes.
Problem I've never run into. Searched without resolution but might not know the right search terms to use. So if already answered I beg pardon.
I had this html. (Kinda long so simplified)
<div class="movieabovewrap">
<div class="movieabove">
LINK TEXT
</div>
And I wanted the link to cover all of the movieabove div so I moved the link outside of it as in.....
<div class="movieabovewrap">
<a href="LINK">
<div class="movieabove">
LINK TEXT
</div>
</a>
(it seems to be cutting off the last end div on both)
Anyways when I moved the link outside the div all the sudden I get this vertical whitespace of about 10px above and below the divs which I assume is attached somehow to the a href element. Assuming as I can't get anything to show up when I inspect the elements. Is there someway to remove this vertical whitespace with css? It kinda trashes my design. :( Any help would be mucho appreciated.
Short answer: Using <span> instead of <div> inside <a> should do the trick for you.
Explanation: The a tag renders a text element, if you want it's children to also act as text elements they must have display: inline.
div elements have display: block by default.
span elements have display: inline by default.
Add display: block to the link, either inline or via css:
<div class="movieabovewrap">
<a href="LINK" style="display: inline-block;">
<div class="movieabove">
LINK TEXT
</div>
</a>
</div
or
.movieabovewrap > a {
display: inline-block;
}
On this website: http://www.livenews.surf/ I want to make news images and text vertically middle align, how i can do that?
Use the following classes in your containing div.row instead of custom CSS as suggested for bootstrap 4.
d-flex flex-wrap align-items-center
The easiest solution is to use Flexbox (see spec. for more details on it's usage).
For this particular case, assign a custom class to each of your content containing div (currently it only has .col-md-11), for example class "content" and add this code to your stylesheet
.content {
display: flex;
align-items: center;
flex-wrap: wrap;
}
Small code explanation: align-items aligns the items vertically, since we left the default flex direction which is row and flex-wrap will allow our parent container to wrap children to next line (default is nowrap).
Keep in mind, that I haven't included vendor prefixes for the sake of this answer, however I would strongly recommend you to do so, using a tool such as Autoprefixer.
Well, As you are using bootstrap columns, so you will need to make by following a couple of steps as explained below:
As a general case html structure of your web page is as follows:
<div class="col-md-11">
<div class="col-md-5">
<a href="#">
<img src="images/image.jgp">
</a>
</div>
<div class="col-md-7">
// text goes here
</div>
</div>
First of all you will need to make the height of both columns (image + text) same. For this you can use jQuery matchHeight.
After that you can make your images vertically centered with the help of following change.
<div class="col-md-5 photo">
<a href="#">
<img src="images/image.jgp">
</a>
</div>
.photo {
display: table;
}
.photo a {
vertical-align: middle;
display: table-cell;
}
.photo img {
display: block;
height: auto;
width: 100%;
}
Here is Plnkr.
This question already has answers here:
How can I wrap text around a non rectangular image?
(5 answers)
Closed 3 years ago.
I am trying to get an image of mine to float in the center of a div. Code currently:
<style type="text/css">
#navig {
height: 333px;
}
#navig img {
display: block;
margin: 0px auto;
}
</style>
<div id="navig"><img src="images/logo.png" height="333" id="logo" /></div>
The trouble is the image is a diamond and I would like the text to wrap around the diamond with the indents. I believe this is a possibility with <img align='center' /> but this was deprecated in HTML 4.01 and not even supported in HTML 5.
I have tried several possibilities and I still cannot get the text to wrap correctly around the diamond.
Refer to this for some options. I have two options, CSS-Shapes and SVG.
The best option current is to use an SVG image but make sure to use the SVG code and not linking it as an image.
Here is a JSFIDDLE, as you can see the text is able to highlight and can be edited. (More of a pain to edit so do your best with the text in AI before saving but it can still be edited)
This is also very flexible as you can see in this FIDDLE.
This is a very new feature and does not have good browser support yet.
SO CSS-Shapes
Once this,
shape-outside: polygon(50px 0px, 100px 100px, 0px 100px);
is supported you will be able to do this with ease.
I recommend learning the basics so once it is supported by most current browsers you will already know what to do.
I managed to figure out a manual way around this. The image remains in the div and is surrounded by two other closed divs tags.
<div id="navig">
<div id="nav1"></div>
<div id="nav2"><img src="images/logo.png" height="333" id="logo" /></div>
<div id="nav3"></div>
</div>
I then make sure all three of these float left: #navig div {float:left;} and the two empty divs are using text-align. The first one will align right and the last one align left.
The two empty divs are then filled with <ul>s and the menu I wanted around it is filled into the <li> tags. For the examples I'll use some basic menu items.
<div id="navig">
<div id="nav1">
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
<div id="nav2">
<img src="images/logo.png" height="333" />
</div>
<div id="nav3">
<ul>
<li>Products</li>
<li>Shipping</li>
<li>Legal</li>
</ul>
</div>
</div>
I then added #nav1 ul li:nth-child(1) and positioned the first element, which would be "Home" against the diamond. I can change "Home" to whatever I fancy and the position remains as it is forced to text-align: right. Adding these with however many <li> items you are using and editing them to suit your needs. For example:
#nav1 ul li:nth-child(1) {
position: relative;
left: 48px;
}
#nav1 ul li:nth-child(2) {
position: relative;
left: 24px;
}
#nav1 ul li:nth-child(3) {
position: relative;
left: 8px;
}
This pushed my first, second and third items over to the diamond but with a little padding so as to not intrude.
A bit of a lengthy process, but plenty of freedom and has given me the desired effect!
You can't do it with just an image.
But you can use shapes, check this page:
https://www.makeuseof.com/tag/csstextwrap/
Using CSSTextWrapper you can easily generate HTML text wraps for any
imaginable shape. It can be circles, zig-zags, triangles or whatever
you want. Quick and simple-to-use, just load the logo (optional) on
the provided dashboard and drag sidelines to define your text wrap.
Quite impressive.