Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <pre><code class= "textoCSS"></code></pre>
<div class = "gradient"></div>


<div class = "leftRight i"></div>
<div class = "topBottom i"></div>
<div class = "circleEllipse i"></div>
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
  background-color: #eee;
  font-size:12px;
}

.gradient {
  width: 300px;
  height: 200px;
  border: 1px solid #d9d9d9;
  margin: 2em auto;
}


.i{width:300px;margin: 1em auto;}
.i *{display:inline-block;}
.i div{width:5.2em; height:1em;}
.i input{margin:0 .5em;}


.textoCSS {
  display: block;
  padding: .2em;
  margin: 0;
  color: #eee;
  background-color: black;
  font-family: courier, monospace;
  line-height:250%;
  white-space:normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.textoCSS mark {
  display: inline-block;
  min-width: 6em;
  padding:.5em;
  line-height:70%;
  text-align: center;
  background-color: orange;
  color: black;
  border-radius: .5em;
  border: 3px solid currentColor
}
.textoCSS mark.ce {background-color: yellow;}
              
            
!

JS

              
                // colores para el degradado
var colorInicial = "yellow";
var colorEnElMedio1 = "gold 50%";
var colorEnElMedio2 = "yellow 55%";
var colorFinal = "tomato";
var color_stops = colorInicial+", "+colorEnElMedio1+","+colorEnElMedio2+", "+colorFinal;

// crea una nueva hoja de estilo
var nuevaHojaDeEstilo = document.createElement("style");
document.head.appendChild(nuevaHojaDeEstilo);
var textoCSS = document.querySelector(".textoCSS");//<pre><code>


inputsRy = [];
var radios = [
  {name:"leftRight",value:"left"},
  {name:"leftRight",value:"right"},
  {name:"leftRight",value:"center"},
  {name:"topBottom",value:"top"},
  {name:"topBottom",value:"bottom"},
  {name:"topBottom",value:"center"},
  {name:"circleEllipse",value:"circle"},
  {name:"circleEllipse",value:"ellipse"}
];

for(var i = 0; i < radios.length; i++){
  var ep = document.querySelector("."+radios[i].name);
  var input = new Input();
  input.att.type = "radio";
  input.att.name = radios[i].name;
  input.att.value = radios[i].value;
  if(radios[i].value == "center" || radios[i].value == "ellipse"){input.att.checked = true;}
  input.crear(ep);
  inputsRy.push(input); 
}



function actualizarCSS() {
  var pos = "";// la posición del centro
  var forma ="ellipse";
  for (var i = 0; i < inputsRy.length; i++) {
    if(inputsRy[i].input.checked == true){
      if(inputsRy[i].att.name !="circleEllipse"){
      pos += inputsRy[i].att.value + " ";
      }else{
      forma = inputsRy[i].att.value + " ";
      }
  }
  pos = isBlank(pos) ? "" : pos+" ";
  cadenaCSS(pos, forma);
}
}






actualizarCSS();

var gradient = document.querySelector(".gradient");

function cadenaCSS(pos,forma){
var pos1 = pos.length > 0 ? "at "+ pos+"," : pos+",";
//background: -webkit-radial-gradient(posición, forma tamaño, color-stops);
var CSSstr = ".gradient{background-image: -webkit-radial-gradient("+pos+" "+forma+" farthest-side, "+color_stops+");}\n";  
//background: radial-gradient(tamaño forma at posición, color-stops);
CSSstr += ".gradient{background-image: radial-gradient(farthest-side "+forma+" "+pos1+" "+color_stops+");}\n";
nuevaHojaDeEstilo.textContent = CSSstr;
var cadenaTextoCSS = CSSstr.replace( /\n/ , "<br>");
cadenaTextoCSS = cadenaTextoCSS.replace( /((at )?(top|bottom|left|right|center)\s*(top|bottom|left|right|center)?)/g , "<mark>$1</mark>"); 
cadenaTextoCSS = cadenaTextoCSS.replace( /(circle|ellipse)/g , "<mark class='ce'>$1</mark>"); 
textoCSS.innerHTML = cadenaTextoCSS; 
}


function isBlank(str) {
    return (!str || /^\s*$/.test(str));
}


for (var n = 0; n < inputsRy.length; n++) {
  (function(n) {
inputsRy[n].input.addEventListener("change", function() {

      inputsRy[n].actualizar();
      actualizarCSS();
      //cadenaCSS("top left,");
    }, false)
  }(n));
}
              
            
!
999px

Console