newcoder1010 Posted May 29, 2017 Share Posted May 29, 2017 Hello, I would like to place a border with an image around an element similar to this one. Please advise or refer me to some resources. So I can try it out. https://drive.google.com/open?id=0B7xIEuVi005yX29uNC1hMDhmZU0 Thanks. Link to comment Share on other sites More sharing options...
dsonesuk Posted May 29, 2017 Share Posted May 29, 2017 (edited) Use a bordered wrap container with position: relative; then add inner element and use position: absolute, with left, property to position it centre horizontally, and half circular image height to position itself halfway between border using negative top: property. OR use content: to create fake type of element to apply background-image, and use same principle as above. .monitor-icon-wrap::after { background: rgba(0, 0, 0, 0) url("monitor.png") no-repeat scroll center center / 100px auto; content: ""; height: 100px; left: 50%; margin-left: -50px; margin-top: -100px; position: absolute; width: 100px; } Edited May 29, 2017 by dsonesuk Link to comment Share on other sites More sharing options...
newcoder1010 Posted May 30, 2017 Author Share Posted May 30, 2017 Sounds complicated. I will let you know. Thanks. Link to comment Share on other sites More sharing options...
newcoder1010 Posted May 30, 2017 Author Share Posted May 30, 2017 (edited) HTML: <div class ="col-md-4 service"> <br> <h2> Service title </h2> <p class = "mytext"> Service descriptionn test test test test test test test test test test test test test test test test test test te test test test test test test test test test test test test test test test test test test test test test test test test test test test test st test </p> </div> CSS: .service { border: 1px solid red; position: relative; } .service::after { background: rgba(0, 0, 0, 0) url(https://www.w3schools.com/html/html5.gif) no-repeat scroll center center / 100px auto; content: ""; height: 50px; left: 50%; margin-left: -50px; margin-top: -100px; position: absolute; width: 100px; } If I give padding to .services class, image relocates to inside the services class. Also, image relocates as I am adding the texts to p class "mytext". Definitely I made progress but I am confused how to place the image in the same place regardless of padding to services class or length of texts in mytext class. Please advise. Edited May 30, 2017 by newcoder1010 Link to comment Share on other sites More sharing options...
dsonesuk Posted May 30, 2017 Share Posted May 30, 2017 Should have used property top: instead margin-top: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" id="viewport" content="target-densitydpi=high-dpi,initial-scale=1.0,user-scalable=no" /> <title>Document Title</title> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> <script type="text/javascript"> </script> <style type="text/css"> .monitor-icon-wrap { border: 1px solid #ccc; margin: 60px 10px 10px; min-height: 312px; padding: 50px 15px 15px; position: relative; width: 460px; border-radius: 10px; } .monitor-icon-wrap::before { background: rgba(0, 0, 0, 0) url("https://www.w3schools.com/html/html5.gif") no-repeat scroll center center / 100px auto; content: ""; height: 100px; left: 50%; margin-left: -50px; position: absolute; top: -50px; width: 100px; } </style> </head> <body> <div class="monitor-icon-wrap"> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> <p> Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius, turpis et commodo pharetra, est eros bibendum elit, nec luctus magna felis sollicitudin mauris. Integer in mauris eu nibh euismod gravida. Duis ac tellus et risus vulputate vehicula. Donec lobortis risus a elit. Etiam tempor. Ut ullamcorper, ligula eu tempor congue, eros est euismod turpis, id tincidunt sapien risus a quam. Maecenas fermentum consequat mi. Donec fermentum. Pellentesque malesuada nulla a mi. Duis sapien sem, aliquet nec, commodo eget, consequat quis, neque. Aliquam faucibus, elit ut dictum aliquet, felis nisl adipiscing sapien, sed malesuada diam lacus eget erat. Cras mollis scelerisque nunc. Nullam arcu. Aliquam consequat. Curabitur augue lorem, dapibus quis, laoreet et, pretium ac, nisi. Aenean magna nisl, mollis quis, molestie eu, feugiat in, orci. In hac habitasse platea dictumst. </p> <p> Fusce convallis, mauris imperdiet gravida bibendum, nisl turpis suscipit mauris, sed placerat ipsum urna sed risus. In convallis tellus a mauris. Curabitur non elit ut libero tristique sodales. Mauris a lacus. Donec mattis semper leo. In hac habitasse platea dictumst. Vivamus facilisis diam at odio. Mauris dictum, nisi eget consequat elementum, lacus ligula molestie metus, non feugiat orci magna ac sem. Donec turpis. Donec vitae metus. Morbi tristique neque eu mauris. Quisque gravida ipsum non sapien. Proin turpis lacus, scelerisque vitae, elementum at, lobortis ac, quam. Aliquam dictum eleifend risus. In hac habitasse platea dictumst. Etiam sit amet diam. Suspendisse odio. Suspendisse nunc. In semper bibendum libero. </p> </div> </body> </html> Link to comment Share on other sites More sharing options...
newcoder1010 Posted May 30, 2017 Author Share Posted May 30, 2017 Thank you so much. It worked out perfect. This is the output. https://drive.google.com/open?id=1AjmH_e1qRmcJYTALE-Ch76cuHRmBWGmrKm5vMRR49RQ Link to comment Share on other sites More sharing options...
newcoder1010 Posted June 9, 2017 Author Share Posted June 9, 2017 .service::after { background: rgba(0, 0, 0, 0) url(https://www.w3schools.com/html/html5.gif) no-repeat scroll center center / 100px auto; content: ""; height: 50px; left: 50%; margin-left: -30px; position: absolute; top: -30px; width: 50px; opacity: .3; background-color: blanchedalmond;//? } Can I put a background color on the above image as well? Link to comment Share on other sites More sharing options...
dsonesuk Posted June 9, 2017 Share Posted June 9, 2017 Yes! You can do exactly the same as with any other element, but in this case the 4 parameter in rgba(0,0,0,0) sets background opacity to 0, so you need to remove this or change to 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now