finding CSS margins and paddings only with 4 parameters by regex - php

I'm going to find all the paddings and margins that only have 4 parameters by regular expression, so created a regexp pattern like this:
(margin|padding)[ ]*:([ ]*((-*\d+(px|em|%|cm|in|pc|pt|mm|ex)?|auto|inherit)[ ]*)(!important)*){4};
But I have found one problem! It also passes this:
margin: 1px 11px 4px;
But I don't know how should solve this problem, also I don't know it has other problems or is it optimized?
Please edit this if possible or offer a new pattern.
Thanks

You just have to remove the ? after unit:
(margin|padding)[ ]*:([ ]*((-*\d+(px|em|%|cm|in|pc|pt|mm|ex)|auto|inherit)[ ]*)(!important)*){4};
Otherwise your regex matches any value with 4 digits at least, whether or not there are units or space in-between.
Then following examples won't match anymore (they did with your regex):
padding: 1111px;
padding: 444px 6px;
padding: 4px 356px;
padding: 44px 36px;
padding: 4px 11px 3px;
padding: 4px 1px 3px 56px;
padding: auto;
padding: 4443px auto;
padding: auto 22356px;
padding: auto 36px 89em;
padding: 42px 11px auto;
padding: 4px auto 3px 56px;
Tested on https://regexr.com/418b9
EDIT: there are new units like vh or vw. And -prefix-calc(10% - 6px). If you're analysing legacy code, no prob ^^ but if you're searching into the wild wild web you may find a few occurences of that.

Related

Random space under first SQL value

I am working on a voting system that shows what people have been voting for, showing the names of the Movies. I have never had this problem before and can't find anything about it online.
Outlined by the red box is the problem, a random space for the first value that is printed.
Here is the code for the text
echo "<br><form method='POST' action='vote.php'>
<font size='5'><center>".$row['moviename']."</center></font>
</center>
And here is the code for the votes bar
.wrap {
margin-right: 500px;
margin-left: 500px;
width: auto;
border: 1px solid #000000;
border-radius: 3px;
background-color: #000000;
padding: 2px;
}
.bar {
background: orange;
height: 24px;
border-radius: 2px;
}
Sorry if this is a stupid question... If you need any more code please ask.
Thanks in advance.

notification bubble badge in ajax

how to get the notification number badge in ajax like Facebook. cant post a picture here but i think people know what am i talking about. its like when you log in to Facebook, if you have new messages you will get a little number on the top right corner of the icons next to search bar. i'm currently found this piece of code in charge of creating that number but i cant go any further from that. here is the code i found.
<span class="jewelCount" id="notificationsCountWrapper">
<span id="notificationsCountValue">1</span>
<i class="accessible_elem"> Notifications</i>
</span>
You want something like that?
Here is the css & jquery solution, if you like. DEMO http://jsfiddle.net/yeyene/DfSda/1/
Add <span class="ballons"></span> inside your button, and replace the dynamic count value.
.ballons {
float:right;
margin:-20px 8px 0 0;
line-height:30px;
padding:0 10px;
border-radius: 30px;
border:3px solid #fff;
border-radius: 30px;
-moz-border-radius: 30px;
-webkit-border-radius: 30px;
-ms-border-radius: 30px;
-o-border-radius: 30px;
background:red;
color:#fff;
text-align:center;
-moz-box-shadow: 1px 1px 3px 3px #ccc;
-webkit-box-shadow: 1px 1px 3px 3px #ccc;
box-shadow: 1px 1px 3px 3px #ccc;
}

Automatic line decoration in HTML + CSS

I've thought about this problem quite a bit.
Is there are way, say, to automatically insert a line decoration after each line (row) in a <div> or just any element that holds text?
For example:
This is the first line
This is the second line
I noticed this problem because underlines aren't ideal, and inserting a div or separating chunks of text in different divs is awkward. Because different characters have different widths in typography, If I used underscores the two lines become uneven in terms of width. I don't think tables can automatically separate a block of text in two rows. Not without some JQuery doing the split.
Is there something that will let define line decorations after lines ?
I need this because the text in the divs are coming from a database. I don't know the length of each line and so it's awkward If I assume a fixed number of characters per line and start chopping words in half at the end of lines,
like,
Hello World Wha
t is up.
Thanks!
Perhaps you can fake it with a "lined paper" effect. Here is one such result: http://css3.wikidot.com/blog:lined-paper-with-css
I'll copy it here to preserve it in case the original site moves or goes down.
The technique is quite simple - all we need is a repeating background gradient to give the effect of lines across the paper, and a pseudo element on the left to give the ruled margin.
.paper {
font: normal 12px/1.5 "Lucida Grande", arial, sans-serif;
width: 300px;
margin: 0 auto 10px;
padding: 6px 5px 4px 42px;
position: relative;
color: #444;
line-height: 20px;
border: 1px solid #d2d2d2;
background: #fff;
background: -webkit-gradient(linear, 0 0, 0 100%, from(#d9eaf3), color-stop(4%, #fff)) 0 4px;
background: -webkit-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px;
background: -moz-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px;
background: -ms-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px;
background: -o-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px;
background: linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px;
-webkit-background-size: 100% 20px;
-moz-background-size: 100% 20px;
-ms-background-size: 100% 20px;
-o-background-size: 100% 20px;
background-size: 100% 20px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.07);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,0.07);
box-shadow: 0 1px 2px rgba(0,0,0,0.07);
}
.paper::before {
content: '';
position: absolute;
width: 4px;
top: 0;
left: 30px;
bottom: 0;
border: 1px solid;
border-color: transparent #efe4e4;
}
In order to get all the text to line up properly on the lines, you need to specifically declare margins and line heights for all text elements. Given we used a background size of 20px above (i.e. it's 20px between the lines), we need to use a line height (or an equivalent line height + margin) of 20px.
.paper h1,
.paper h2 {
font-size: 16px;
line-height: 16px;
margin: 0 0 4px;
}
.paper h3,
.paper h4,
.paper h5 {
font-size: 14px;
line-height: 16px;
margin: 0 0 4px;
}
.paper h4,
.paper h5 {
font-weight: normal;
}
.paper p {margin: 0 0 20px;}
.paper p:last-child {margin: 0;}
.paper ul {margin: 0 0 20px;}
Browser support
It works perfectly in Webkit and Opera, and almost perfectly in Firefox (the ruled margins on the left are 1 pixel too short at one end). Theoretically it should work in IE10, but I haven't tested it.
Another way would be to just create an 1xN.png with 1 pixel filled in at the bottom. and set that as your background-image. Where N equals the line height like below:
<--- Just a speck.
You could also convert the image into a data URI if you are worried about adding an extra request.
CSS
div {
background-image: url("1x16.png");
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAQCAYAAADXnxW3AAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFP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ueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAABlJREFUeNpi+P//PwMTAwMD5QQDAwPDf8AA7wsEGVDzcpsAAAAASUVORK5CYII=);
line-height: 16px;
}

Space between my recent posts in wordpress

I'm looking for ages to figure out how to add some space between my recent posts on a wordpress site.
Really have no idea. Anybody that could help?
You have 2 style statements that pretty directly affect these. One has bottom margin but is being overridden by another with margin: 0;. Change this to margin: 0 0 20px 0;.
.primary_content_wrap ul li {
background: url(images/marker.gif) no-repeat 1px 11px;
margin: 0;
padding: 0 0 0 17px;
list-style: none;
line-height: 25px;
font-size: 13px;
color: #005d9e;
}
.recent-posts li {
margin: 0 0 20px 0;
padding: 0;
border: none;
}
each of your posts is a li with an "entry" class :
<li class="entry">...</li>
it seems there's nothing in any CSS for that entry class. What I would do is define it in the CSS with a margin-bottom set to, let's say 10px.

basic CSS label aligning

Hi basically I am new to css etc so my form may be awful, however last night it was appearing abosloutely fine....I haven't touched it, and on loading the site this morning it is not appearing correctly.
so here is my jsfiddle,
can somebody wise please explain why its changed over night? I am sure I haven't touched it.
thanks,
All you need to do is add clear: left to:
#stylized label {
clear: left;
display: block;
float: left;
font-weight: bold;
padding-bottom: 12px;
padding-left: 2px;
padding-right: 2px;
padding-top: 3px;
text-align: right;
width: 180px;
}
http://jsfiddle.net/userdude/7Zc6u/5/
What's happening is the edge of the password label is getting caught on the edge of the username label.
replacing padding
padding: 5px 3px 2px 12px; to #stylized label solves the problem
Or use
clear:left; in #stylized label

Categories